| | |
| | | if($data['new']['ipv6_address'] != '') $tpl->setVar('ipv6_enabled', 1); |
| | | |
| | | // PHP-FPM |
| | | $pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); |
| | | // Support for multiple PHP versions |
| | | if(trim($data['new']['fastcgi_php_version']) != ''){ |
| | | $default_php_fpm = false; |
| | | list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version'])); |
| | | if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/'; |
| | | } else { |
| | | $default_php_fpm = true; |
| | | } |
| | | |
| | | if($default_php_fpm){ |
| | | $pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); |
| | | } else { |
| | | $pool_dir = $custom_php_fpm_pool_dir; |
| | | } |
| | | if(substr($pool_dir,-1) != '/') $pool_dir .= '/'; |
| | | $pool_name = 'web'.$data['new']['domain_id']; |
| | | $socket_dir = escapeshellcmd($web_config['php_fpm_socket_dir']); |
| | |
| | | global $app, $conf; |
| | | //$reload = false; |
| | | |
| | | if(trim($data['new']['fastcgi_php_version']) != ''){ |
| | | $default_php_fpm = false; |
| | | list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version'])); |
| | | if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/'; |
| | | } else { |
| | | $default_php_fpm = true; |
| | | } |
| | | |
| | | $app->uses("getconf"); |
| | | $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); |
| | | |
| | | if($data['new']['php'] == 'no'){ |
| | | if(@is_file($pool_dir.$pool_name.'.conf')){ |
| | | unlink($pool_dir.$pool_name.'.conf'); |
| | | //$reload = true; |
| | | } |
| | | if($data['old']['php'] != 'no'){ |
| | | if(!$default_php_fpm){ |
| | | $app->services->restartService('php-fpm','reload:'.$custom_php_fpm_init_script); |
| | | } else { |
| | | $app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); |
| | | } |
| | | } |
| | | //if($reload == true) $app->services->restartService('php-fpm','reload'); |
| | | return; |
| | | } |
| | | |
| | | $app->uses("getconf"); |
| | | $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); |
| | | |
| | | |
| | | $app->load('tpl'); |
| | | $tpl = new tpl(); |
| | | $tpl->newTemplate('php_fpm_pool.conf.master'); |
| | |
| | | file_put_contents($pool_dir.$pool_name.'.conf',$tpl->grab()); |
| | | $app->log('Writing the PHP-FPM config file: '.$pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG); |
| | | unset($tpl); |
| | | |
| | | // delete pool in all other PHP versions |
| | | $default_pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); |
| | | if(substr($default_pool_dir,-1) != '/') $default_pool_dir .= '/'; |
| | | if($default_pool_dir != $pool_dir){ |
| | | if ( @is_file($default_pool_dir.$pool_name.'.conf') ) { |
| | | unlink($default_pool_dir.$pool_name.'.conf'); |
| | | $app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG); |
| | | $app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); |
| | | } |
| | | } |
| | | $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$conf["server_id"]); |
| | | if(is_array($php_versions) && !empty($php_versions)){ |
| | | foreach($php_versions as $php_version){ |
| | | if(substr($php_version['php_fpm_pool_dir'],-1) != '/') $php_version['php_fpm_pool_dir'] .= '/'; |
| | | if($php_version['php_fpm_pool_dir'] != $pool_dir){ |
| | | if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) { |
| | | unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf'); |
| | | $app->log('Removed PHP-FPM config file: '.$php_version['php_fpm_pool_dir'].$pool_name.'.conf',LOGLEVEL_DEBUG); |
| | | $app->services->restartService('php-fpm','reload:'.$php_version['php_fpm_init_script']); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // Reload current PHP-FPM after all others |
| | | sleep(1); |
| | | if(!$default_php_fpm){ |
| | | $app->services->restartService('php-fpm','reload:'.$custom_php_fpm_init_script); |
| | | } else { |
| | | $app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); |
| | | } |
| | | |
| | | //$reload = true; |
| | | |
| | | //if($reload == true) $app->services->restartService('php-fpm','reload'); |
| | |
| | | |
| | | //* Delete the PHP-FPM pool configuration file |
| | | private function php_fpm_pool_delete ($data,$web_config) { |
| | | global $app; |
| | | global $app, $conf; |
| | | |
| | | $pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); |
| | | if(trim($data['old']['fastcgi_php_version']) != ''){ |
| | | $default_php_fpm = false; |
| | | list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['old']['fastcgi_php_version'])); |
| | | if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/'; |
| | | } else { |
| | | $default_php_fpm = true; |
| | | } |
| | | |
| | | if($default_php_fpm){ |
| | | $pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); |
| | | } else { |
| | | $pool_dir = $custom_php_fpm_pool_dir; |
| | | } |
| | | |
| | | if(substr($pool_dir,-1) != '/') $pool_dir .= '/'; |
| | | $pool_name = 'web'.$data['old']['domain_id']; |
| | | |
| | | if ( @is_file($pool_dir.$pool_name.'.conf') ) { |
| | | unlink($pool_dir.$pool_name.'.conf'); |
| | | $app->log('Removed PHP-FPM config file: '.$pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG); |
| | | |
| | | //$app->services->restartService('php-fpm','reload'); |
| | | } |
| | | |
| | | // delete pool in all other PHP versions |
| | | $default_pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); |
| | | if(substr($default_pool_dir,-1) != '/') $default_pool_dir .= '/'; |
| | | if($default_pool_dir != $pool_dir){ |
| | | if ( @is_file($default_pool_dir.$pool_name.'.conf') ) { |
| | | unlink($default_pool_dir.$pool_name.'.conf'); |
| | | $app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG); |
| | | $app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); |
| | | } |
| | | } |
| | | $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$data['old']['server_id']); |
| | | if(is_array($php_versions) && !empty($php_versions)){ |
| | | foreach($php_versions as $php_version){ |
| | | if(substr($php_version['php_fpm_pool_dir'],-1) != '/') $php_version['php_fpm_pool_dir'] .= '/'; |
| | | if($php_version['php_fpm_pool_dir'] != $pool_dir){ |
| | | if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) { |
| | | unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf'); |
| | | $app->log('Removed PHP-FPM config file: '.$php_version['php_fpm_pool_dir'].$pool_name.'.conf',LOGLEVEL_DEBUG); |
| | | $app->services->restartService('php-fpm','reload:'.$php_version['php_fpm_init_script']); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // Reload current PHP-FPM after all others |
| | | sleep(1); |
| | | if(!$default_php_fpm){ |
| | | $app->services->restartService('php-fpm','reload:'.$custom_php_fpm_init_script); |
| | | } else { |
| | | $app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); |
| | | } |
| | | } |
| | | |
| | | function client_delete($event_name,$data) { |