Commit 62e4b35e authored by Falko Timme's avatar Falko Timme

- Apache: added support for multiple PHP-FPM versions.

- Fastcgi: delete .php-fcgi-starter directory if another PHP mode is used.
parent 27436212
......@@ -38,6 +38,7 @@ $app->uses('getconf');
$server_id = intval($_GET["server_id"]);
$web_id = intval($_GET["web_id"]);
$php_type = $_GET["php_type"];
$type = $_GET["type"];
//if($_SESSION["s"]["user"]["typ"] == 'admin') {
......@@ -67,16 +68,17 @@ $type = $_GET["type"];
$server_type = 'apache';
$web_config = $app->getconf->get_server_config($server_id, 'web');
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
if($server_type == 'nginx'){
$sql = "SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = $server_id";
} else {
$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id";
if($server_type == 'nginx' && $php_type == 'fast-cgi') $php_type = 'php-fpm';
if($php_type == 'php-fpm'){
$php_records = $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 = $server_id");
}
if($php_type == 'fast-cgi'){
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id");
}
$php_records = $app->db->queryAllRecords($sql);
$php_select = "";
if(is_array($php_records) && !empty($php_records)) {
foreach( $php_records as $php_record) {
if($server_type == 'nginx'){
if($php_type == 'php-fpm'){
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
} else {
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
......
......@@ -91,5 +91,5 @@ $wb['pm_min_spare_servers_error_regex'] = 'PHP-FPM pm.min_spare_servers mu&szlig
$wb['pm_max_spare_servers_error_regex'] = 'PHP-FPM pm.max_spare_servers muß eine positive ganze Zahl sein.';
$wb['hd_quota_error_regex'] = 'Harddisk Quota ist ungültig.';
$wb['traffic_quota_error_regex'] = 'Traffic Quota ist ungültig.';
$wb["fastcgi_php_version_txt"] = 'FastCGI-PHP-Version';
$wb["fastcgi_php_version_txt"] = 'PHP-Version';
?>
......@@ -91,5 +91,5 @@ $wb["pm_min_spare_servers_error_regex"] = 'PHP-FPM pm.min_spare_servers must be
$wb["pm_max_spare_servers_error_regex"] = 'PHP-FPM pm.max_spare_servers must be a positive integer value.';
$wb["hd_quota_error_regex"] = 'Harddisk quota is invalid.';
$wb["traffic_quota_error_regex"] = 'Traffic quota is invalid.';
$wb["fastcgi_php_version_txt"] = 'FastCGI PHP Version';
$wb["fastcgi_php_version_txt"] = 'PHP Version';
?>
\ No newline at end of file
......@@ -167,13 +167,14 @@
reloadWebIP();
});
if(jQuery('#php').val() == 'fast-cgi'){
if(jQuery('#php').val() == 'fast-cgi' || jQuery('#php').val() == 'php-fpm'){
jQuery('.fastcgi_php_version:hidden').show();
} else {
jQuery('.fastcgi_php_version:visible').hide();
}
jQuery('#php').change(function(){
if(jQuery(this).val() == 'fast-cgi'){
reloadFastcgiPHPVersions();
if(jQuery(this).val() == 'fast-cgi' || jQuery(this).val() == 'php-fpm'){
jQuery('.fastcgi_php_version:hidden').show();
} else {
jQuery('.fastcgi_php_version:visible').hide();
......@@ -206,7 +207,7 @@
}
function reloadFastcgiPHPVersions() {
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getphpfastcgi"}, function(data) {
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, php_type : jQuery('#php').val(), type : "getphpfastcgi"}, function(data) {
var options = '<option value="">Default</option>';
var phpfastcgiselected = '';
$.each(data, function(key, val) {
......
......@@ -135,16 +135,17 @@ class page_action extends tform_actions {
$server_type = 'apache';
$web_config = $app->getconf->get_server_config($client['default_webserver'], 'web');
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
if($server_type == 'nginx'){
$sql = "SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
} else {
$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
if($this->dataRecord['php'] == 'php-fpm'){
$php_records = $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 = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
}
if($this->dataRecord['php'] == 'fast-cgi'){
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
}
$php_records = $app->db->queryAllRecords($sql);
$php_select = "<option value=''>Default</option>";
if(is_array($php_records) && !empty($php_records)) {
foreach( $php_records as $php_record) {
if($server_type == 'nginx'){
if($this->dataRecord['php'] == 'php-fpm'){
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
} else {
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
......@@ -216,16 +217,17 @@ class page_action extends tform_actions {
$server_type = 'apache';
$web_config = $app->getconf->get_server_config($client['default_webserver'], 'web');
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
if($server_type == 'nginx'){
$sql = "SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
} else {
$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
if($this->dataRecord['php'] == 'php-fpm'){
$php_records = $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 = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
}
if($this->dataRecord['php'] == 'fast-cgi') {
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$client['default_webserver']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
}
$php_records = $app->db->queryAllRecords($sql);
$php_select = "<option value=''>Default</option>";
if(is_array($php_records) && !empty($php_records)) {
foreach( $php_records as $php_record) {
if($server_type == 'nginx'){
if($this->dataRecord['php'] == 'php-fpm'){
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
} else {
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
......@@ -288,16 +290,17 @@ class page_action extends tform_actions {
$server_type = 'apache';
$web_config = $app->getconf->get_server_config($server_id, 'web');
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
if($server_type == 'nginx'){
$sql = "SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = $server_id";
} else {
$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id";
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
if($this->dataRecord['php'] == 'php-fpm'){
$php_records = $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 = $server_id");
}
if($this->dataRecord['php'] == 'fast-cgi') {
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id");
}
$php_records = $app->db->queryAllRecords($sql);
$php_select = "<option value=''>Default</option>";
if(is_array($php_records) && !empty($php_records)) {
foreach( $php_records as $php_record) {
if($server_type == 'nginx'){
if($this->dataRecord['php'] == 'php-fpm'){
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
} else {
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
......
......@@ -960,18 +960,38 @@ class apache2_plugin {
$tpl->setVar('fastcgi_starter_script',$fastcgi_config['fastcgi_starter_script']);
$tpl->setVar('fastcgi_config_syntax',$fastcgi_config['fastcgi_config_syntax']);
} else {
//remove the php fastgi starter script if available
if ($data['old']['php'] == 'fast-cgi') {
$fastcgi_config = $app->getconf->get_server_config($conf['server_id'], 'fastcgi');
$fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$fastcgi_config['fastcgi_starter_path']);
$fastcgi_starter_path = str_replace('[client_id]',$client_id,$fastcgi_starter_path);
if (is_dir($fastcgi_starter_path)) {
exec('rm -rf '.$fastcgi_starter_path);
}
}
}
/**
* PHP-FPM
*/
// 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 .= '/';
if($data['new']['php'] == 'php-fpm'){
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;
}
} else {
$default_php_fpm = true;
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
$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){
......@@ -1926,12 +1946,22 @@ class apache2_plugin {
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 .= '/';
if($data['new']['php'] == 'php-fpm'){
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;
}
} else {
$default_php_fpm = true;
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
$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;
}
}
$app->uses("getconf");
......@@ -2070,7 +2100,7 @@ class apache2_plugin {
private function php_fpm_pool_delete ($data,$web_config) {
global $app, $conf;
if(trim($data['old']['fastcgi_php_version']) != ''){
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
$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 .= '/';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment