

1οΈβ£ Apa itu Nginx & Apache (ringkas tapi jelas)
πΉ Apache
- Web server paling lama & populer
- Cocok untuk shared hosting
- Konfigurasi banyak lewat
.htaccess
πΉ Nginx (dibaca: engine-x)
- Web server modern & super cepat
- Cocok untuk VPS & high traffic
- Tidak pakai
.htaccess, semua diatur di config server
2οΈβ£ Cara Kerja (ini kunci perbedaannya)
Apache β Process / Thread Based
- Setiap request = proses / thread baru
- Kalau traffic tinggi β RAM cepat habis
Nginx β Event Driven (Asynchronous)
- 1 worker bisa handle ribuan request
- Sangat irit RAM & CPU
π Kesimpulan singkat
Apache kuat & fleksibel
Nginx cepat, ringan, dan scalable
3οΈβ£ Penggunaan Nginx untuk Website (Real Case)
π§ Arsitektur umum Nginx
Client (Browser)
β
Nginx (Web Server)
β
PHP-FPM (PHP Engine)
β
MySQL / MariaDB
π Nginx tidak menjalankan PHP langsung
β‘οΈ PHP dijalankan oleh PHP-FPM
4οΈβ£ Contoh Konfigurasi Website di Nginx
π Virtual Host (Server Block)
File:
/etc/nginx/sites-available/namadomain.conf
Contoh:
server {
listen 80;
server_name namadomain.com www.namadomain.com;
root /var/www/namadomain;
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.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Aktifkan:
ln -s /etc/nginx/sites-available/namadomain.conf \
/etc/nginx/sites-enabled/
nginx -t
systemctl reload nginx
5οΈβ£ Perbedaan Apache vs Nginx (Tabel Ringkas)
| Aspek | Apache | Nginx |
|---|---|---|
| Performa | Stabil | π₯ Sangat cepat |
| Konsumsi RAM | Lebih besar | Sangat hemat |
.htaccess | β Ya | β Tidak |
| PHP | Langsung | Via PHP-FPM |
| Traffic tinggi | Kurang optimal | β Sangat kuat |
| Shared Hosting | Cocok | Kurang cocok |
| VPS / Cloud | Bisa | π₯ Ideal |
6οΈβ£ Kenapa Banyak VPS Pakai Nginx?
β Lebih cepat load website
β Cocok untuk WordPress + cache
β Lebih aman (tidak expose .htaccess)
β Skalabilitas tinggi
β Ideal untuk banyak website dalam 1 VPS
Inilah alasan LiteSpeed & OpenLiteSpeed sering disebut βalternatif Apache modernβ
7οΈβ£ Kapan Pilih Apache?
Gunakan Apache jika:
- Pakai shared hosting
- Bergantung pada
.htaccess - Banyak rewrite rule lama
- Tidak mau ribet konfigurasi
8οΈβ£ Kapan Pilih Nginx? (Rekomendasi buat kamu)
Gunakan Nginx jika:
- Pakai VPS
- Hosting banyak website
- WordPress + caching
- Fokus ke speed & SEO
- Mau setup profesional
π Dari histori pertanyaan kamu β Nginx lebih cocok π
9οΈβ£ Kombinasi Terbaik (Pro Level)
π₯ Nginx + PHP-FPM + Redis + OPcache
π₯ Nginx sebagai reverse proxy Apache
π₯ Nginx + WordPress + FastCGI Cache
