Optimalisasi Server
Konfigurasi MPM Event Apache
Setup Apache ke MPM Event + PHP-FPM
1️⃣ Cek MPM Apache yang aktif
apachectl -V | grep -i mpm
-
mpm_prefork❌ → harus diganti -
mpm_event✅ → sudah benar
2️⃣ Nonaktifkan MPM Prefork dan PHP 8.1
sudo a2dismod mpm_prefork
sudo a2dismod php8.1
3️⃣ Aktifkan MPM Event
sudo a2enmod mpm_event
4️⃣ Aktifkan Integrasi Apache ↔ PHP-FPM
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.1-fpm
5️⃣ Restart Apache & PHP-FPM
sudo systemctl restart php8.1-fpm
sudo systemctl restart apache2
6️⃣ Pastikan MPM Event Aktif
apachectl -V | grep -i mpm
Output harus:
Server MPM: event
7️⃣ Optimasi untuk Server Ram Besar
sudo nano /etc/apache2/mods-available/mpm_event.conf
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 400
MaxConnectionsPerChild 5000
</IfModule>
sudo systemctl restart apache2
Konfigurasi Apache MPM Prefork + PHP (mod_php)
1️⃣ Nonaktifkan PHP-FPM
sudo systemctl stop php8.1-fpm
sudo systemctl disable php8.1-fpm
Nonaktifkan konfigurasi Apache FPM:
sudo a2disconf php8.1-fpm
sudo a2dismod proxy_fcgi
2️⃣ Aktifkan MPM Prefork
Matikan MPM Event:
sudo a2dismod mpm_event
Aktifkan Prefork:
sudo a2enmod mpm_prefork
3️⃣ Pastikan mod_php sesuai versi PHP terpasang:
sudo apt install libapache2-mod-php8.1
sudo a2enmod php8.1
4️⃣ Restart Apache Prefork
sudo systemctl restart php81.-fpm
sudo systemctl restart apache2
5️⃣ Cek MPM:
apachectl -V | grep -i mpm
Harus muncul:
Server MPM: prefork
6️⃣ Optimasi Prefork
sudo nano /etc/apache2/mods-available/mpm_prefork.conf
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 3000
</IfModule>
sudo systemctl restart apache2