Switching to php-fpm and Apache 2 mpm_event Worker Instead of mpm_prefork in Debian 10

Switching to PHP-FPM

Starting with a fairly stock Debian 10 PHP/Apache2 install which defaults to the mpm_prefork module and mod_php. It seems to be safe to install php-fpm in place, as it won't clobber the existing PHP and Apache configuration:

sudo apt install php-fpm

See the following comments after the install:

Creating config file /etc/php/7.3/fpm/php.ini with new version
NOTICE: Not enabling PHP 7.3 FPM by default.
NOTICE: To enable PHP 7.3 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.3-fpm
NOTICE: You are seeing this message because you have apache2 package installed.

So now we just need to enable the additional apache modules to support php-fpm:

a2enmod proxy_fcgi setenvif
a2enconf php7.3-fpm

The old mod_php config/module is safe to disable; it's config is located in /etc/apache2/mods-enabled/php7.3.conf; disable the module with:

sudo a2dismod php7.3                                                                                                                        

At this point once the apache process is restarted, the php-fpm configuration will take over.

Switching to the mpm_event Apache Module

Simple as disabling the prefork module, and enabling the event module as follows:

sudo a2dismod mpm_prefork
sudo a2enmod mpm_event

Restart apache and voila.

The configuration file for the mpm_event module is located at /etc/apache2/mods-enabled/mpm_event.conf. Good luck with that configuration; here are some (hopefully up-to-date and helpful) tips.

Tags

 Debian 10  Apache 2.4  Apache  system administration  linux  PHP  PHP-FPM