Skip to content

Commit 62e4b35

Browse files
committed
- Apache: added support for multiple PHP-FPM versions.
- Fastcgi: delete .php-fcgi-starter directory if another PHP mode is used.
1 parent 2743621 commit 62e4b35

File tree

6 files changed

+76
-40
lines changed

6 files changed

+76
-40
lines changed

interface/web/sites/ajax_get_json.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
$server_id = intval($_GET["server_id"]);
4040
$web_id = intval($_GET["web_id"]);
41+
$php_type = $_GET["php_type"];
4142
$type = $_GET["type"];
4243

4344
//if($_SESSION["s"]["user"]["typ"] == 'admin') {
@@ -67,16 +68,17 @@
6768
$server_type = 'apache';
6869
$web_config = $app->getconf->get_server_config($server_id, 'web');
6970
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
70-
if($server_type == 'nginx'){
71-
$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";
72-
} else {
73-
$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id";
71+
if($server_type == 'nginx' && $php_type == 'fast-cgi') $php_type = 'php-fpm';
72+
if($php_type == 'php-fpm'){
73+
$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");
74+
}
75+
if($php_type == 'fast-cgi'){
76+
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id");
7477
}
75-
$php_records = $app->db->queryAllRecords($sql);
7678
$php_select = "";
7779
if(is_array($php_records) && !empty($php_records)) {
7880
foreach( $php_records as $php_record) {
79-
if($server_type == 'nginx'){
81+
if($php_type == 'php-fpm'){
8082
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
8183
} else {
8284
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];

interface/web/sites/lib/lang/de_web_domain.lng

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ $wb['pm_min_spare_servers_error_regex'] = 'PHP-FPM pm.min_spare_servers mu&szlig
9191
$wb['pm_max_spare_servers_error_regex'] = 'PHP-FPM pm.max_spare_servers muß eine positive ganze Zahl sein.';
9292
$wb['hd_quota_error_regex'] = 'Harddisk Quota ist ungültig.';
9393
$wb['traffic_quota_error_regex'] = 'Traffic Quota ist ungültig.';
94-
$wb["fastcgi_php_version_txt"] = 'FastCGI-PHP-Version';
94+
$wb["fastcgi_php_version_txt"] = 'PHP-Version';
9595
?>

interface/web/sites/lib/lang/en_web_domain.lng

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ $wb["pm_min_spare_servers_error_regex"] = 'PHP-FPM pm.min_spare_servers must be
9191
$wb["pm_max_spare_servers_error_regex"] = 'PHP-FPM pm.max_spare_servers must be a positive integer value.';
9292
$wb["hd_quota_error_regex"] = 'Harddisk quota is invalid.';
9393
$wb["traffic_quota_error_regex"] = 'Traffic quota is invalid.';
94-
$wb["fastcgi_php_version_txt"] = 'FastCGI PHP Version';
94+
$wb["fastcgi_php_version_txt"] = 'PHP Version';
9595
?>

interface/web/sites/templates/web_domain_edit.htm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,14 @@ <h2><tmpl_var name="list_head_txt"></h2>
167167
reloadWebIP();
168168
});
169169

170-
if(jQuery('#php').val() == 'fast-cgi'){
170+
if(jQuery('#php').val() == 'fast-cgi' || jQuery('#php').val() == 'php-fpm'){
171171
jQuery('.fastcgi_php_version:hidden').show();
172172
} else {
173173
jQuery('.fastcgi_php_version:visible').hide();
174174
}
175175
jQuery('#php').change(function(){
176-
if(jQuery(this).val() == 'fast-cgi'){
176+
reloadFastcgiPHPVersions();
177+
if(jQuery(this).val() == 'fast-cgi' || jQuery(this).val() == 'php-fpm'){
177178
jQuery('.fastcgi_php_version:hidden').show();
178179
} else {
179180
jQuery('.fastcgi_php_version:visible').hide();
@@ -206,7 +207,7 @@ <h2><tmpl_var name="list_head_txt"></h2>
206207
}
207208

208209
function reloadFastcgiPHPVersions() {
209-
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getphpfastcgi"}, function(data) {
210+
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, php_type : jQuery('#php').val(), type : "getphpfastcgi"}, function(data) {
210211
var options = '<option value="">Default</option>';
211212
var phpfastcgiselected = '';
212213
$.each(data, function(key, val) {

interface/web/sites/web_domain_edit.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,17 @@ function onShowEnd() {
135135
$server_type = 'apache';
136136
$web_config = $app->getconf->get_server_config($client['default_webserver'], 'web');
137137
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
138-
if($server_type == 'nginx'){
139-
$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'].")";
140-
} else {
141-
$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'].")";
138+
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
139+
if($this->dataRecord['php'] == 'php-fpm'){
140+
$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'].")");
141+
}
142+
if($this->dataRecord['php'] == 'fast-cgi'){
143+
$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'].")");
142144
}
143-
$php_records = $app->db->queryAllRecords($sql);
144145
$php_select = "<option value=''>Default</option>";
145146
if(is_array($php_records) && !empty($php_records)) {
146147
foreach( $php_records as $php_record) {
147-
if($server_type == 'nginx'){
148+
if($this->dataRecord['php'] == 'php-fpm'){
148149
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
149150
} else {
150151
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
@@ -216,16 +217,17 @@ function onShowEnd() {
216217
$server_type = 'apache';
217218
$web_config = $app->getconf->get_server_config($client['default_webserver'], 'web');
218219
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
219-
if($server_type == 'nginx'){
220-
$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'].")";
221-
} else {
222-
$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'].")";
220+
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
221+
if($this->dataRecord['php'] == 'php-fpm'){
222+
$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'].")");
223+
}
224+
if($this->dataRecord['php'] == 'fast-cgi') {
225+
$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'].")");
223226
}
224-
$php_records = $app->db->queryAllRecords($sql);
225227
$php_select = "<option value=''>Default</option>";
226228
if(is_array($php_records) && !empty($php_records)) {
227229
foreach( $php_records as $php_record) {
228-
if($server_type == 'nginx'){
230+
if($this->dataRecord['php'] == 'php-fpm'){
229231
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
230232
} else {
231233
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];
@@ -288,16 +290,17 @@ function onShowEnd() {
288290
$server_type = 'apache';
289291
$web_config = $app->getconf->get_server_config($server_id, 'web');
290292
if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
291-
if($server_type == 'nginx'){
292-
$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";
293-
} else {
294-
$sql = "SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id";
293+
if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
294+
if($this->dataRecord['php'] == 'php-fpm'){
295+
$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");
296+
}
297+
if($this->dataRecord['php'] == 'fast-cgi') {
298+
$php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = $server_id");
295299
}
296-
$php_records = $app->db->queryAllRecords($sql);
297300
$php_select = "<option value=''>Default</option>";
298301
if(is_array($php_records) && !empty($php_records)) {
299302
foreach( $php_records as $php_record) {
300-
if($server_type == 'nginx'){
303+
if($this->dataRecord['php'] == 'php-fpm'){
301304
$php_version = $php_record['name'].':'.$php_record['php_fpm_init_script'].':'.$php_record['php_fpm_ini_dir'].':'.$php_record['php_fpm_pool_dir'];
302305
} else {
303306
$php_version = $php_record['name'].':'.$php_record['php_fastcgi_binary'].':'.$php_record['php_fastcgi_ini_dir'];

server/plugins-available/apache2_plugin.inc.php

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -960,18 +960,38 @@ function update($event_name,$data) {
960960
$tpl->setVar('fastcgi_starter_script',$fastcgi_config['fastcgi_starter_script']);
961961
$tpl->setVar('fastcgi_config_syntax',$fastcgi_config['fastcgi_config_syntax']);
962962

963+
} else {
964+
//remove the php fastgi starter script if available
965+
if ($data['old']['php'] == 'fast-cgi') {
966+
$fastcgi_config = $app->getconf->get_server_config($conf['server_id'], 'fastcgi');
967+
$fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$fastcgi_config['fastcgi_starter_path']);
968+
$fastcgi_starter_path = str_replace('[client_id]',$client_id,$fastcgi_starter_path);
969+
if (is_dir($fastcgi_starter_path)) {
970+
exec('rm -rf '.$fastcgi_starter_path);
971+
}
972+
}
963973
}
964974

965975
/**
966976
* PHP-FPM
967977
*/
968978
// Support for multiple PHP versions
969-
if(trim($data['new']['fastcgi_php_version']) != ''){
970-
$default_php_fpm = false;
971-
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']));
972-
if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
979+
if($data['new']['php'] == 'php-fpm'){
980+
if(trim($data['new']['fastcgi_php_version']) != ''){
981+
$default_php_fpm = false;
982+
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']));
983+
if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
984+
} else {
985+
$default_php_fpm = true;
986+
}
973987
} else {
974-
$default_php_fpm = true;
988+
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
989+
$default_php_fpm = false;
990+
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']));
991+
if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
992+
} else {
993+
$default_php_fpm = true;
994+
}
975995
}
976996

977997
if($default_php_fpm){
@@ -1926,12 +1946,22 @@ private function php_fpm_pool_update ($data,$web_config,$pool_dir,$pool_name,$so
19261946
global $app, $conf;
19271947
//$reload = false;
19281948

1929-
if(trim($data['new']['fastcgi_php_version']) != ''){
1930-
$default_php_fpm = false;
1931-
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']));
1932-
if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
1949+
if($data['new']['php'] == 'php-fpm'){
1950+
if(trim($data['new']['fastcgi_php_version']) != ''){
1951+
$default_php_fpm = false;
1952+
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']));
1953+
if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
1954+
} else {
1955+
$default_php_fpm = true;
1956+
}
19331957
} else {
1934-
$default_php_fpm = true;
1958+
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
1959+
$default_php_fpm = false;
1960+
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']));
1961+
if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';
1962+
} else {
1963+
$default_php_fpm = true;
1964+
}
19351965
}
19361966

19371967
$app->uses("getconf");
@@ -2070,7 +2100,7 @@ private function php_fpm_pool_update ($data,$web_config,$pool_dir,$pool_name,$so
20702100
private function php_fpm_pool_delete ($data,$web_config) {
20712101
global $app, $conf;
20722102

2073-
if(trim($data['old']['fastcgi_php_version']) != ''){
2103+
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
20742104
$default_php_fpm = false;
20752105
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']));
20762106
if(substr($custom_php_fpm_ini_dir,-1) != '/') $custom_php_fpm_ini_dir .= '/';

0 commit comments

Comments
 (0)