(Auto Install Nginx + MariaDB + PHP 8.3 + Extensions + APT Repo via GitHub)

Materi ini dibuat agar bisa:

  • VPS baru install sekali
  • Auto setup webserver production basic
  • Ringan (cocok VPS 1GB)
  • Bisa dipanggil via apt install alfa-webstack

1. Desain Arsitektur Service yang Akan Dibuat

Nama paket:

alfa-webstack

Saat dijalankan:

sudo apt install alfa-webstack -y

Akan otomatis:

  1. Install Nginx (web server)
  2. Install MariaDB (database)
  3. Install PHP 8.3 + extensions lengkap
  4. Setup folder web /var/www/html
  5. Enable dan start semua service (systemd)
  6. Konfigurasi dasar server siap deploy

2. Dependency yang Akan Digunakan (Isi Otomatis Paket)

Paket utama yang akan di-auto install:

nginx
mariadb-server
php8.3
php8.3-fpm
php8.3-cli
php8.3-mysql
php8.3-curl
php8.3-xml
php8.3-mbstring
php8.3-zip
php8.3-gd
php8.3-intl
unzip
curl

Fungsi:

  • nginx → webserver
  • mariadb → database
  • php-fpm → eksekusi PHP
  • extensions → kompatibel WordPress & web app

3. Struktur Project Package (.deb)

Buat di mesin build (local atau VPS builder):

mkdir -p alfa-webstack/DEBIAN
mkdir -p alfa-webstack/usr/local/bin
mkdir -p alfa-webstack/lib/systemd/system
mkdir -p alfa-webstack/etc/nginx/sites-available

Struktur akhir:

alfa-webstack/
├── DEBIAN/
│ ├── control
│ └── postinst
├── usr/local/bin/alfa-webstack
├── lib/systemd/system/alfa-webstack.service
├── etc/nginx/sites-available/alfa-default.conf

4. Membuat File Control (Metadata APT Package)

File:

alfa-webstack/DEBIAN/control

Isi:

Package: alfa-webstack
Version: 1.0
Section: web
Priority: optional
Architecture: all
Depends: nginx, mariadb-server, php8.3, php8.3-fpm, php8.3-cli, php8.3-mysql, php8.3-curl, php8.3-xml, php8.3-mbstring, php8.3-zip, php8.3-gd, php8.3-intl, curl, unzip
Maintainer: Alfa DevOps <admin@alfa.local>
Description: Automated LEMP Webstack Installer (Nginx + MariaDB + PHP 8.3 + Extensions)

Fungsi:

  • Depends → APT auto install semua komponen stack
  • Architecture all → bisa dipakai di banyak sistem Linux berbasis Debian/Ubuntu

5. Membuat Script Automation Utama (Core Service)

File:

alfa-webstack/usr/local/bin/alfa-webstack

Isi:

#!/bin/bashecho "[ALFA] Starting Webstack Automation..."

# Create web directory
mkdir -p /var/www/html
chmod -R 755 /var/www/html

# Create test PHP file
cat <<EOF > /var/www/html/info.php
<?php phpinfo(); ?>
EOF

# Configure Nginx default site
cat <<EOF > /etc/nginx/sites-available/alfa-default.conf
server {
listen 80;
server_name _;
root /var/www/html;
index index.php index.html; location / {
try_files \$uri \$uri/ /index.php?\$args;
} location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
}
EOF

# Enable site
ln -sf /etc/nginx/sites-available/alfa-default.conf /etc/nginx/sites-enabled/alfa-default.conf

# Enable services
systemctl enable nginx
systemctl enable mariadb
systemctl enable php8.3-fpm# Restart services
systemctl restart nginx
systemctl restart mariadb
systemctl restart php8.3-fpmecho "[ALFA] Webstack Installation Completed!"

Fungsi script:

  • Setup web root
  • Setup PHP handler
  • Enable service systemd
  • Auto restart service stack

6. Membuat Systemd Service

File:

alfa-webstack/lib/systemd/system/alfa-webstack.service

Isi:

[Unit]
Description=Alfa Automated Webstack Setup Service
After=network.target nginx.service mariadb.service php8.3-fpm.service[Service]
Type=oneshot
ExecStart=/usr/local/bin/alfa-webstack
RemainAfterExit=true[Install]
WantedBy=multi-user.target

Fungsi:

  • Menjalankan automation hanya sekali saat install
  • Tetap terdaftar sebagai service systemd

7. Membuat Post-Install Script (Otomatis Saat apt install)

File:

alfa-webstack/DEBIAN/postinst

Isi:

#!/bin/bash
set -eecho "[ALFA] Running Post Installation..."# Reload systemd
systemctl daemon-reload# Enable and start automation service
systemctl enable alfa-webstack
systemctl start alfa-webstackecho "[ALFA] Setup Finished Successfully"

Fungsi:

  • Otomatis dijalankan setelah install paket
  • Register service ke systemd
  • Jalankan auto setup tanpa manual command

8. Set Permission (Wajib)

chmod 755 alfa-webstack/DEBIAN/postinst
chmod 755 alfa-webstack/usr/local/bin/alfa-webstack

Tanpa ini, package bisa gagal install.


9. Build Package .deb

Install tools:

sudo apt install dpkg-dev -y

Build:

dpkg-deb --build alfa-webstack

Output:

alfa-webstack.deb

10. Membuat Repository APT di GitHub (Static Repo)

Langkah profesional agar bisa:

sudo apt install alfa-webstack

langsung dari internet.

Step A — Buat Repository GitHub

Nama repo disarankan:

alfa-apt-repo

Struktur repo:

repo/
├── alfa-webstack.deb
├── Packages
└── Packages.gz

Step B — Generate Index Repository

Di folder repo lokal:

mkdir repo
cp alfa-webstack.deb repo/
cd repo
dpkg-scanpackages . /dev/null > Packages
gzip -9c Packages > Packages.gz

Fungsi:

  • Packages → index paket APT
  • Packages.gz → versi terkompresi untuk apt

Step C — Upload ke GitHub

Upload isi folder repo/ ke:

https://github.com/USERNAME/alfa-apt-repo

Lalu aktifkan GitHub Pages:
Settings → Pages → Deploy from branch → main / root

URL repo APT nanti:

https://USERNAME.github.io/alfa-apt-repo

11. Cara Install di VPS Baru (Final Workflow)

Di VPS fresh:

sudo apt update
sudo apt install curl -y

Tambahkan repo:

echo "deb [trusted=yes] https://USERNAME.github.io/alfa-apt-repo ./" | sudo tee /etc/apt/sources.list.d/alfa.list

Update index:

sudo apt update

Install webstack:

sudo apt install alfa-webstack -y

12. Apa yang Terjadi Saat Command Install Dijalankan (Urutan Sistem)

Urutan internal:

  1. APT membaca repo GitHub
  2. Download Packages.gz
  3. Mendeteksi alfa-webstack.deb
  4. Install dependency (nginx, mariadb, php)
  5. Ekstrak file ke filesystem
  6. Register systemd service
  7. Jalankan postinst script
  8. Automation script deploy stack
  9. Server siap digunakan

13. Hasil Akhir Setelah Install

Service yang aktif:

systemctl status nginx
systemctl status mariadb
systemctl status php8.3-fpm
systemctl status alfa-webstack

Folder otomatis:

/var/www/html
/etc/nginx/
/usr/local/bin/alfa-webstack

Test di browser:

http://IP-VPS/info.php

Jika muncul phpinfo → stack berhasil.


14. Catatan Penting (Real World DevOps Insight)

Untuk VPS 1GB RAM:

  • MariaDB + PHP + Nginx masih aman
  • Jangan tambahkan terlalu banyak extension
  • Hindari install paket berat seperti elasticsearch

15. Upgrade Kedepan (Level Production)

Versi selanjutnya service kamu bisa ditambah:

  • Auto SSL (certbot)
  • Firewall (ufw)
  • Docker support
  • Redis cache
  • Auto WordPress installer

Dan nanti kamu tinggal:

apt install alfa-webstack-pro

Tanpa setup manual lagi.

By Admin

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *