Apache2 : PHP + PHP-FPM
rev 2026/05/25
|
Install PHP-FPM (FPM : FastCGI Process Manager) to make PHP scripts be fast. |
|
| [1] | |
| [2] | Install PHP-FPM. |
|
root@www:~# apt -y install php8.5-fpm
|
| [3] | Enable PHP-FPM. |
|
# installing PHP automatically enables mod_php, so disable it root@www:~# a2dismod php8.5 Module php8.5 disabled. To activate the new configuration, you need to run: systemctl restart apache2 # Ubuntu uses the Event MPM by default, but enabling mod_php switches it to the Prefork MPM # revert to the Event MPM if necessary root@www:~# a2dismod mpm_prefork Module mpm_prefork disabled. To activate the new configuration, you need to run: systemctl restart apache2root@www:~# a2enmod mpm_event Considering conflict mpm_worker for mpm_event: Considering conflict mpm_prefork for mpm_event: Enabling module mpm_event. To activate the new configuration, you need to run: systemctl restart apache2 # enable PHP-FPM root@www:~# a2enmod proxy_fcgi setenvif Considering dependency proxy for proxy_fcgi: Enabling module proxy. Enabling module proxy_fcgi. Module setenvif already enabled To activate the new configuration, you need to run: systemctl restart apache2root@www:~# a2enconf php8.5-fpm Enabling conf php8.3-fpm. To activate the new configuration, you need to run: systemctl reload apache2root@www:~# systemctl restart php8.5-fpm apache2
|
| [4] | Create [phpinfo] in Virtualhost's web-root you set PHP-FPM and access to it, then that's OK if [FPM/FastCGI] is displayed. |
|
root@www:~# echo '<?php phpinfo(); ?>' > /var/www/html/info.php |
|
