multiple php-fpm versions on ispconfig: switch php-version error

Discussion in 'Installation/Configuration' started by durchd8.de, Oct 11, 2015.

  1. durchd8.de

    durchd8.de Member

    CentOS Linux release 7.1.1503 (Core)
    ISPConfig version is 3.0.5.4p8

    Issue:
    When switching php-fpm versions from Default (5.4.16) to php7RC4, ispconfig doesnt properly restart phpRC4-fpm to pick up the new pool. I need to restart phpRC4-fpm manually once. On the reverse switch of php-versions from RC4 to php5.4, something similar happens. Pools are correctly adjusted, but apparently php7RC4-fpm is not restarted, thus keeping the old pool, which listens on the approbriate socket. Therefore php-fpm 5.4.16 can not start. To fix this, I have to restart both services: php7RC4-fpm and php-fpm.
    Bottom line: version switch by ispconfig doesnt really work automatically, but lacks a restart :(

    What I checked:
    1. created an initd script
    2. name and patch of initd script is correct in ispconfig
    3. pools are properly rewritten by ispconfig in both php-fpm
    4. tested my init script and systemd config: by service, directly and systemctl - all ok

    What I did before:
    - compiled and installed php7RC4 in seperate directory ( /opt/phpRC4 )
    - added php7RC4-fpm data to ispconfig as new php-Version

    No clue whats going on :( Please help
     
  2. durchd8.de

    durchd8.de Member

    Tried the same with an additional php-version: php5.6.14 and same issue: ispconfig can not switch from Default to php5.6 and back. Apparently a restart of the additional php versions to activate or deactivate pool does not happen when needed.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

  4. durchd8.de

    durchd8.de Member

    OS is CentOS 7.1 with systemd. Yet I created the init scripts since both still work together on 7.1

    In log/messages I only see the default php-fpm restarted, all other fpm's are aparently not restarted.

    How does ispconfig3 restart the php-fpm of additional php-versions? What is needed to successfully restart fpm of additional php-versions?

    Also I dont see a logfile for ispconfig.
     
  5. durchd8.de

    durchd8.de Member

    PS: Yes I also verified on the tutorials, yet had to stray from those since its CentOS 7.1
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    You have to add a systemd unit then as ispconfig will use systemd when it is installed. See here for an example on how such a systemd unit can look like: https://www.howtoforge.com/tutorial/install-php-7-on-debian-8-jessie/
     
  7. durchd8.de

    durchd8.de Member

    Thank you - got that one. Question: how does ispconfig know, which systemd-service corresponds to which php-version? Apparently some name or similar do not match, so that ispconfig doesnt know which service it is.
     
  8. durchd8.de

    durchd8.de Member

    Or do I just enter the path tot he systemd config file in ispconfig under: Path to the PHP-FPM init script ?
     
  9. durchd8.de

    durchd8.de Member

    status:
    - the systemd-files are created: phpRC4-fpm.service and php-5.6-fpm.service
    - all init scripts do exist and work for each fpm
    - can use the fpm-services normally with systemctl
     

    Attached Files:

  10. durchd8.de

    durchd8.de Member

    Turns out ispconfig3 has issues with multiple php-fpm versions under CentOS7.
    Code:
                                            // And the next workaround, php-fpm reloads in centos 7 downt work as well.
                                            if(preg_match('/^ID=centos/m', $tmp) && preg_match('/^VERSION_ID="7"/m', $tmp)) {
                                                    $initcommand = 'systemctl restart php-fpm.service';
                                            }
                                            unset($tmp);
    
    Bottom line: ispconfig3 only accesses php-fpm.service. Any other service files for php-fpm are ignored.

    Suggestion:
    - bugfix for ispconfig adding another field to enter systemd service name
     
    Madalin Ignisca likes this.
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Plaese make a bugreport in the bugtracker, I'll check that for the 3.1 release.
     
  12. vtochq

    vtochq New Member

    Hi. I have same issues with multi PHP-FPM installation on my CentOS7 with systemd.
    I fix problem by changing function restartPHP_FPM in /usr/local/ispconfig/server/mods-available/web_module.inc.php
    Usefull variable is a $init_script. I make systemd reload string based on it.
    $initcommand = 'systemctl reload '.substr(strrchr($init_script,'/'),1);

    Code:
           function restartPHP_FPM($action = 'restart') {
    
                    global $app, $conf;
    
                    // load the server configuration options
                    $app->uses('getconf,system');
                    $web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
    
                    list($action, $init_script) = explode(':', $action);
    
                    if(!$init_script){
                            //$init_script = $conf['init_scripts'].'/'.$web_config['php_fpm_init_script'];
                            $initcommand = $app->system->getinitcommand($web_config['php_fpm_init_script'], $action);
                    } else {
                            $path_parts = pathinfo($init_script);
                            $initcommand = $app->system->getinitcommand($path_parts['basename'], $action, $path_parts['dirname']);
    
                            if($action == 'reload' && $init_script == $conf['init_scripts'].'/'.$web_config['php_fpm_init_script']) {
                                    // we have to do a workaround because of buggy ubuntu fpm reload handling
                                    // @see: https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1242376
                                    if(file_exists('/etc/os-release')) {
                                            $tmp = file_get_contents('/etc/os-release');
                                            if(preg_match('/^ID=ubuntu/m', $tmp) && preg_match('/^VERSION_ID="14\.04"/m', $tmp)) {
                                                    $initcommand = '/sbin/start-stop-daemon --stop --signal USR2 --quiet --pidfile /var/run/php5-fpm.pid --name php5-fpm';
                                            }
                                            // And the next workaround, php-fpm reloads in centos 7 downt work as well.
                                            //if(preg_match('/^ID=centos/m', $tmp) && preg_match('/^VERSION_ID="7"/m', $tmp)) {
                                            //      $initcommand = 'systemctl restart php-fpm.service';
                                            //}
                                            unset($tmp);
                                    }
                            }
    
                            if($action == 'reload') {
                                    //And the next workaround, php-fpm reloads in centos 7 downt work as well.
                                    if(file_exists('/etc/os-release')) {
                                            $tmp = file_get_contents('/etc/os-release');
                                            // And the next workaround, php-fpm reloads in centos 7 downt work as well.
                                            if(preg_match('/^ID="centos"/m', $tmp) && preg_match('/^VERSION_ID="7"/m', $tmp)) {
                                                    //$initcommand = 'systemctl restart php-fpm.service';
                                                    $initcommand = 'systemctl reload '.substr(strrchr($init_script,'/'),1);
                                            }
                        unset($tmp);
                                    }
                            }
    
                    }
    
                    $retval = array('output' => '', 'retval' => 0);
                    exec($initcommand.' 2>&1', $retval['output'], $retval['retval']);
                    $app->log("Restarting php-fpm: $initcommand", LOGLEVEL_DEBUG);
                    return $retval;
            }
    
     
    till likes this.

Share This Page