PHP-FPM reload mode "restart" ignored when using Nginx webserver
Summary
When using Nginx as webserver, the PHP-FPM reload mode is totally ignored. No matters you put reload or restart, ISPConfig always reload PHP-FPM.
Steps to reproduce
- Install ISPConfig with Nginx
- Install additional PHP version
- Enable debug mode and set PHP-FPM reload mode to "restart"
- Create/edit site with PHP-FPM enabled and choose a version
- Look at logs
Correct behaviour
ISPConfig should restart PHP-FPM instead of reload if this is specified like this in the configuration.
Environment
Server OS + version: Debian 11.1 ISPConfig version: 3.2.11 Software version of the related software:
root@server:~# nginx -v
nginx version: nginx/1.18.0
root@server:~# php8.1 -v
PHP 8.1.0 (cli) (built: Nov 25 2021 20:48:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies
(This is the PHP 8.1 from deb.sury.org repository)
Proposed fix
The problem is on nginx_plugin.inc.php
line 3054, the reload mode is hardcoded to "reload":
$app->services->restartService('php-fpm', 'reload:'.$php_version['php_fpm_init_script']);
Instead of hardcoding like this, we can reuse the code on apache2_plugin.inc.php
to get the reload mode and use it properly:
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
$php_fpm_reload_mode = ($web_config['php_fpm_reload_mode'] == 'reload')?'reload':'restart';
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$web_config['php_fpm_init_script']);
Related log entries
26.09.2023-08:26 - DEBUG [nginx plugin.inc:3032] - Writing the PHP-FPM config file: /etc/php/8.1/fpm/pool.d/web5.conf
26.09.2023-08:26 - DEBUG [services.inc:56] - Calling function 'restartPHP_FPM' from module 'web_module'.
26.09.2023-08:26 - DEBUG [system.inc:2083] - Trying to use Systemd to restart service
26.09.2023-08:26 - DEBUG [system.inc:2431] - safe_exec cmd: systemctl is-enabled 'php8.1-fpm' 2>&1 - return code: 0
26.09.2023-08:26 - DEBUG [system.inc:2098] - ######################################reload php8.1-fpm
26.09.2023-08:26 - DEBUG [web module.inc:316] - Restarting php-fpm: systemctl reload php8.1-fpm.service