Question
Why Thecpanel_php_fpm
Service Is Automatically Restarted On My Server?
Answer
Before attempting to answer this question, there is a very important distinction that needs to be made. There are two different types of PHP-FPM services/executables on a cPanel server.
apache_php_fpm
The first type of PHP-FPM services are those that are integrated into Apache as an alternative FastCGI daemon for PHP executed by Apache that allows a website to handle significant loads. It allows a host to set specific amounts of resources to process a domain’s requests via workers available to respond to PHP requests (pools).
The PHP-FPM executables for this type of PHP-FPM service are located here:
/opt/cpanel/ea-php##/root/usr/sbin/php-fpm
And the script for managing these services is this:
/usr/local/cpanel/scripts/restartsrv_apache_php_fpm
This script runs all php-fpm executables that are located above and that have been activated by the user. The script runs these executables in the background and in demonized mode with the following option:
/opt/cpanel/ea-php##/root/usr/sbin/php-fpm --daemonize
cpanel_php_fpm
There is, however, another type of PHP-FPM service/executable that's not used by Apache but it's reserved for cPanel's (cpsrvd) internal use and that's the cpanel_php_fpm service.
PHP-FPM service for cPanel Daemons (cpanel_php_fpm
) — This daemon improves the performance of PHP-based internal applications that ship with cPanel & WHM, such as:
-
phpMyAdmin
-
phpPgAdmin
-
Webmail applications
-
Any third-party PHP application that the user installs.
The script for managing this PHP-FPM service is this:
/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm
And the script initializes the following executables: (The version number ## matches the version of the so-called "system PHP" chosen by the user)
/usr/local/cpanel/3rdparty/php/##/sbin/php-fpm --daemonize
- - - - - - - - - - - - - - - - - - - - - - - - - -
Now back to the answer.
Why Thecpanel_php_fpm
Service Is Automatically Restarted On My Server?
As you can see the question is referring to the cpanel_php_fpm service and that's the cPanel internal PHP-FPM service and not the apache_php_fpm or anything related to Apache processes.
As explained earlier cpanel_php_fpm is used by, and in certain cases is a requirement for, "any third-party PHP application that the user installs". This means any application, plugin or module that is either natively integrated into the cPanel environment or added later which has any components written in PHP and of course that would include plugins like WP Toolkit.
In the case of WP Toolkit, the cpanel_php_fpm service is actually a hard requirement, meaning that if you have the WP Toolkit installed on your server, as a part of its installation script the WP Toolkit plugin automatically installs the PHP-FPM service, if it's not already installed, and sets it to enabled.
Here you can find the functions responsible for this mentioned both in WP Toolkit's installation script and also in the install-rpm.sh script from the wp-toolkit-cpanel package:
rpm -q --scripts wp-toolkit-cpanel | grep -Ei enableCpanelFpmDaemons -A 5
enableCpanelFpmDaemons()
{
rm -f /etc/cpanel_php_fpmdisable
/usr/local/cpanel/scripts/cpservice cpanel_php_fpm enable
/usr/local/cpanel/scripts/restartsrv cpanel_php_fpm
}
grep -Ei enableCpanelFpmDaemons /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh -A 5
enableCpanelFpmDaemons()
{
rm -f /etc/cpanel_php_fpmdisable
/usr/local/cpanel/scripts/cpservice cpanel_php_fpm enable
/usr/local/cpanel/scripts/restartsrv cpanel_php_fpm
}
In order to confirm that WP Toolkit is responsible for restarting the cpanel_php_fpm service you can run the following command:
grep -Eir ".*start.*cpanel_php_fpm.*install-rpm.sh" /usr/local/cpanel/logs/*
The output of this command should list all the instances where the cpanel_php_fpm service has been enabled/restarted by WP Toolkit as a part of its installation or update process.
The output looks like this:
grep -Eir ".*start.*cpanel_php_fpm.*install-rpm.sh" /usr/local/cpanel/logs/*
/usr/local/cpanel/logs/error_log:[2021-04-27 00:55:52 -0500]: “/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm ” called by (16005 - bash /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh)
/usr/local/cpanel/logs/error_log:[2021-04-30 00:58:05 -0500]: “/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm ” called by (16837 - bash /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh)
/usr/local/cpanel/logs/error_log:[2021-05-20 00:58:36 -0500]: “/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm ” called by (16513 - bash /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh)
/usr/local/cpanel/logs/error_log:[2021-05-23 08:36:46 -0500]: “/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm ” called by (5428 - bash /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh)
/usr/local/cpanel/logs/error_log:[2021-06-02 00:57:04 -0500]: “/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm ” called by (25360 - bash /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh)
/usr/local/cpanel/logs/error_log:[2021-06-10 04:23:17 -0500]: “/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm ” called by (3917 - bash /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh)
/usr/local/cpanel/logs/error_log:[2021-06-17 06:55:21 -0500]: “/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm ” called by (30006 - bash /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh)
/usr/local/cpanel/logs/error_log:[2021-07-01 04:09:00 -0500]: “/usr/local/cpanel/scripts/restartsrv_cpanel_php_fpm ” called by (25874 - bash /usr/local/cpanel/3rdparty/wp-toolkit/bin/install-rpm.sh)