Additional PHP version socket placed in default directory

Summary

So, sites which have a PHP version different from the default one gets the socket created in the default PHP socket folder regardless of which version you select. This is due to a SELECT in apache2_plugin.inc.php:

$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];

this gets the directory from this query:

$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);

however if you take a look at the SQL file for the database creation:

CREATE TABLE `server_php` (
  `server_php_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `sys_userid` int(11) unsigned NOT NULL DEFAULT '0',
  `sys_groupid` int(11) unsigned NOT NULL DEFAULT '0',
  `sys_perm_user` varchar(5) DEFAULT NULL,
  `sys_perm_group` varchar(5) DEFAULT NULL,
  `sys_perm_other` varchar(5) DEFAULT NULL,
  `server_id` int(11) unsigned NOT NULL DEFAULT '0',
  `client_id` int(11) unsigned NOT NULL DEFAULT '0',
  `name` varchar(255) DEFAULT NULL,
  `php_fastcgi_binary` varchar(255) DEFAULT NULL,
  `php_fastcgi_ini_dir` varchar(255) DEFAULT NULL,
  `php_fpm_init_script` varchar(255) DEFAULT NULL,
  `php_fpm_ini_dir` varchar(255) DEFAULT NULL,
  `php_fpm_pool_dir` varchar(255) DEFAULT NULL,
  `php_fpm_socket_dir` varchar(255) DEFAULT NULL,
  `active` enum('n','y') NOT NULL DEFAULT 'y',
  PRIMARY KEY (`server_php_id`)
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

You can see there is no custom_php_fpm_socket_dir, so:

 if (!$default_php_fpm && !empty($custom_php_fpm_socket_dir)) {
  $socket_dir = $custom_php_fpm_socket_dir;
 } else {
  $socket_dir = $web_config['php_fpm_socket_dir'];
 }

It defaults to the directory specified in the default PHP version settings.

Environment

Server OS + version: Centos8
ISPConfig version: 3.2.4

Software version of the related software:

Server version: Apache/2.4.37 (centos)

Proposed fix

The proposed fix is easy:

diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 19f650d4b..f5437493c 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -1658,7 +1658,7 @@ class apache2_plugin {
                                        $custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
                                        $custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
                                        $custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
-                                       $custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
+                                       $custom_php_fpm_socket_dir = $tmp_php['php_fpm_socket_dir'];
                                        if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
                                }
                        }
@@ -1670,7 +1670,7 @@ class apache2_plugin {
                                        $custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
                                        $custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
                                        $custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
-                                       $custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
+                                       $custom_php_fpm_socket_dir = $tmp_php['php_fpm_socket_dir'];
                                        if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
                                }
                        }

I'll also create a merge request if necessary.

Thanks,

Tommaso.

EDIT: Added Merge request: !1490 (merged)

Edited by Tommaso Perondi