I’m setting up a new web LAMP VPS that happened to include php-fpm configured by default with the default settings and I’ve been using regular php for a long time, and I’m not familiar with php-fpm, so I’m wondering if it’s possible to disable php-fpm and switch to regular php.
So the question is, using the terminal via SSH, how to disable php-fpm without uninstalling it and switching to regular php?
The server is using Ubuntu 22.04, PHP 8.2.6, Apache 2.4.52, and MariaDB 10.
I have run the php -v command, and the output was:
PHP 8.2.6 (cli) (built: May 12 2023 06:24:00) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.6, Copyright (c) Zend Technologies
with Zend OPcache v8.2.6, Copyright (c), by Zend Technologies
with Xdebug v3.2.0, Copyright (c) 2002-2022, by Derick Rethans
Also, is php-fpm part of php, right? I’m assuming that the regular php is already installed since fpm is available, so I don’t have to install anything else to switch, correct?
Update: To add a little more clarity to the question. I’m a LAMP server to host a WordPress site, and I want to disable php-fpm to use the regular PHP so I don’t have to change the virtual host files or configure the www-fpm.
2
Answers
While it may be that your problem lies somewhere other than with PHP-FPM, it is noteworthy that previous to PHP-FPM, PHP would run as a module to Apache itself known as mod_php.
This approach was common up until PHP 5 but the introduction of PHP-FPM resulted in significant performance improvements, making it a preferred choice.
However, this is still a possibility to use with Apache 2, as documented in php.net.
While this is possible, please note that php-fpm is not known to cause any issues when paired with WordPress, and that the problem may exist elsewhere.
There are 4 different ways I know of to integrate PHP with Apache – I don’t which of the other 3 you refer to as "regular PHP". However since you’re talking about WordPress, then I don’t think you’d like the performance of CGI / suPHP, which just leaves mod_php.
While mod_php has a very slight performance advantage of php-fpm, it significantly impacts the capacity of your server (particularly if you don’t know how to tune it). It also avoids any conflicts between the MPM modules in your Apache and your PHP extensions. Which rather begs the question what do you expect to achieve by doing this?
But you said it came pre-configured?
First check that your Apache httpd is running as pre-fork. If not you’ll need to change that. Next, check if the Apache/PHP stack is installed via apt – if it’s not, then you’ll need to unpick it all manually. Since (I believe) mod_php is no longer available in the standard Ubuntu repos you’ll need to source the relevant software – adding a PPA would be more sensible than using tarballs. Then uninstall the php-fpm package and install the mod_php package.
Leaving aside the changes to the performance characteristics, mod_php is going to create a LOT more work for you than sticking with PHP_FPM.