How to Disable or Enable PHP FPM

PHP-FPM (PHP FastCGI Process Manager) is a key element in web server performance optimization. This guide will show you how to effortlessly disable or enable PHP-FPM as needed, giving you control over your server’s PHP processing.

If you are looking for more articles related to PHP-FPM, click on the link below.

Disable PHP FPM

If you have enabled PHP FPM and wish to disable it for any reason, please continue reading.

These commands may also work on other distributions with Apache as the web server, but I will be demonstrating them on Ubuntu (22.04).

The first step is to disable the PHP FPM Apache configuration.

a2disconf php8.1-fpm

Next we will disable Apache module mpm_event and enable mpm_prefork.

a2dismod mpm_event
a2enmod mpm_prefork

The final step is to enable the Apache module for PHP now.

a2enmod php8.1

If everything goes well, check the Apache configuration and restart Apache, including stopping PHP FPM.

apachectl -t
systemctl restart apache2
systemctl stop php8.1-fpm

Enable

If you need to enable PHP FPM in the future, here’s how to do it.

Enable Apache PHP FPM configuration first and then disable the Apache module for PHP.

a2enconf php8.1-fpm
a2dismod php8.1

Disable mpm_prefork and enable mpm_event.

a2dismod mpm_prefork
a2enmod mpm_event

And lastly restart Apache and start PHP FPM.

apachectl -t
systemctl restart apache2
systemctl start php8.1-fpm

Leave a Reply

Your email address will not be published. Required fields are marked *