From 62b385fcdae1fbbad37548626f48ed8c33db9ba9 Mon Sep 17 00:00:00 2001 From: ftimme Date: Tue, 6 Mar 2012 19:42:09 +0000 Subject: [PATCH] - Added support for multiple PHP versions (Apache + PHP-FastCGI). --- install/sql/incremental/upd_0031.sql | 1 + install/sql/ispconfig3.sql | 1 + install/tpl/server.ini.master | 1 + .../web/admin/form/server_config.tform.php | 8 +++ .../web/admin/lib/lang/de_server_config.lng | 2 + .../web/admin/lib/lang/en_server_config.lng | 2 + .../templates/server_config_fastcgi_edit.htm | 4 ++ .../sites/ajax_get_fastcgi_php_versions.php | 58 +++++++++++++++++++ interface/web/sites/form/web_domain.tform.php | 11 ++++ .../web/sites/lib/lang/de_web_domain.lng | 1 + .../web/sites/lib/lang/en_web_domain.lng | 1 + .../web/sites/templates/web_domain_edit.htm | 19 ++++++ interface/web/sites/web_domain_edit.php | 41 ++++++++++++- .../plugins-available/apache2_plugin.inc.php | 21 ++++++- 14 files changed, 168 insertions(+), 3 deletions(-) create mode 100644 install/sql/incremental/upd_0031.sql create mode 100644 interface/web/sites/ajax_get_fastcgi_php_versions.php diff --git a/install/sql/incremental/upd_0031.sql b/install/sql/incremental/upd_0031.sql new file mode 100644 index 000000000..f14e1264a --- /dev/null +++ b/install/sql/incremental/upd_0031.sql @@ -0,0 +1 @@ +ALTER TABLE `web_domain` ADD `fastcgi_php_version` VARCHAR( 255 ) NULL DEFAULT NULL; \ No newline at end of file diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 8055d8277..a755adfa3 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -1549,6 +1549,7 @@ CREATE TABLE `web_domain` ( `backup_copies` INT NOT NULL DEFAULT '1', `active` enum('n','y') NOT NULL default 'y', `traffic_quota_lock` enum('n','y') NOT NULL default 'n', + `fastcgi_php_version` varchar(255) DEFAULT NULL, PRIMARY KEY (`domain_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index 275fa7ace..9f6f30cc8 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -90,6 +90,7 @@ fastcgi_children=8 fastcgi_max_requests=5000 fastcgi_bin=/usr/bin/php-cgi fastcgi_config_syntax=1 +fastcgi_additional_php_versions= [jailkit] jailkit_chroot_home=/home/[username] diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index 24f3f18c6..facc193e4 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -867,6 +867,14 @@ $form["tabs"]['fastcgi'] = array( 'width' => '40', 'maxlength' => '255' ), + 'fastcgi_additional_php_versions' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), ################################## # ENDE Datatable fields ################################## diff --git a/interface/web/admin/lib/lang/de_server_config.lng b/interface/web/admin/lib/lang/de_server_config.lng index fd78f1bce..7911e9481 100644 --- a/interface/web/admin/lib/lang/de_server_config.lng +++ b/interface/web/admin/lib/lang/de_server_config.lng @@ -153,4 +153,6 @@ $wb['set_folder_permissions_on_update_txt'] = 'Set folder permissions on update' $wb['add_web_users_to_sshusers_group_txt'] = 'Add web users to -sshusers- group'; $wb['connect_userid_to_webid_txt'] = 'Connect Linux userid to webid'; $wb['connect_userid_to_webid_start_txt'] = 'Start ID for userid/webid connect'; +$wb["fastcgi_additional_php_versions_txt"] = 'Zusätzliche PHP-Versionen'; +$wb["fastcgi_additional_php_versions_hint_txt"] = 'Format:
<name>;<path_to_executable>;<path_to_php.ini_dir>
z.B.:
PHP 5.2.17;/opt/php52/bin/php-cgi;/opt/php52/etc/'; ?> diff --git a/interface/web/admin/lib/lang/en_server_config.lng b/interface/web/admin/lib/lang/en_server_config.lng index 4cce27548..c6a80f2de 100644 --- a/interface/web/admin/lib/lang/en_server_config.lng +++ b/interface/web/admin/lib/lang/en_server_config.lng @@ -157,4 +157,6 @@ $wb["connect_userid_to_webid_txt"] = 'Connect Linux userid to webid'; $wb["connect_userid_to_webid_start_txt"] = 'Start ID for userid/webid connect'; $wb["realtime_blackhole_list_txt"] = 'Real-time Blackhole List'; $wb["realtime_blackhole_list_note_txt"] = '(Separate RBL\'s with commas)'; +$wb["fastcgi_additional_php_versions_txt"] = 'Additional PHP Versions'; +$wb["fastcgi_additional_php_versions_hint_txt"] = 'Format:
<name>;<path_to_executable>;<path_to_php.ini_dir>
e.g.:
PHP 5.2.17;/opt/php52/bin/php-cgi;/opt/php52/etc/'; ?> \ No newline at end of file diff --git a/interface/web/admin/templates/server_config_fastcgi_edit.htm b/interface/web/admin/templates/server_config_fastcgi_edit.htm index 3ca49c5d6..0f051f5b6 100644 --- a/interface/web/admin/templates/server_config_fastcgi_edit.htm +++ b/interface/web/admin/templates/server_config_fastcgi_edit.htm @@ -39,6 +39,10 @@ {tmpl_var name='fastcgi_config_syntax'} +
+ + {tmpl_var name='fastcgi_additional_php_versions_hint_txt'} +
diff --git a/interface/web/sites/ajax_get_fastcgi_php_versions.php b/interface/web/sites/ajax_get_fastcgi_php_versions.php new file mode 100644 index 000000000..41d2536e5 --- /dev/null +++ b/interface/web/sites/ajax_get_fastcgi_php_versions.php @@ -0,0 +1,58 @@ +auth->check_module_permissions('sites'); + +$server_id = intval($_GET["server_id"]); +$client_group_id = intval($_GET["client_group_id"]); + +if($_SESSION["s"]["user"]["typ"] == 'admin' or $app->auth->has_clients($_SESSION['s']['user']['userid'])) { + + $app->uses('ini_parser,getconf'); + $fastcgi = $app->getconf->get_server_config($server_id,'fastcgi'); + $php_versions = explode('\n',$fastcgi['fastcgi_additional_php_versions']); + + $php_select = ""; + + if(is_array($php_versions)) { + foreach( $php_versions as $php_version) { + $php_select .= "#$php_version"; + } + } + + unset($php_versions); +} + +echo $php_select; +?> \ No newline at end of file diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php index af05cdfa1..5e79c1940 100644 --- a/interface/web/sites/form/web_domain.tform.php +++ b/interface/web/sites/form/web_domain.tform.php @@ -210,6 +210,17 @@ $form["tabs"]['domain'] = array ( 'valuelimit' => 'client:web_php_options', 'value' => array('no' => 'disabled_txt', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP') ), + 'fastcgi_php_version' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '', + /*'datasource' => array ( 'type' => 'SQL', + 'querystring' => "SELECT ip_address,ip_address FROM server_ip WHERE ip_type = 'IPv4' AND {AUTHSQL} ORDER BY ip_address", + 'keyfield'=> 'ip_address', + 'valuefield'=> 'ip_address' + ),*/ + 'value' => '' + ), 'ruby' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', diff --git a/interface/web/sites/lib/lang/de_web_domain.lng b/interface/web/sites/lib/lang/de_web_domain.lng index 2cfebf216..27a74ba9b 100644 --- a/interface/web/sites/lib/lang/de_web_domain.lng +++ b/interface/web/sites/lib/lang/de_web_domain.lng @@ -89,4 +89,5 @@ $wb['pm_max_children_error_regex'] = 'PHP-FPM pm.max_children muß eine pos $wb['pm_start_servers_error_regex'] = 'PHP-FPM pm.start_servers muß eine positive ganze Zahl sein.'; $wb['pm_min_spare_servers_error_regex'] = 'PHP-FPM pm.min_spare_servers muß eine positive ganze Zahl sein.'; $wb['pm_max_spare_servers_error_regex'] = 'PHP-FPM pm.max_spare_servers muß eine positive ganze Zahl sein.'; +$wb["fastcgi_php_version_txt"] = 'FastCGI-PHP-Version'; ?> diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng index b7fcc679f..bd6becf7b 100644 --- a/interface/web/sites/lib/lang/en_web_domain.lng +++ b/interface/web/sites/lib/lang/en_web_domain.lng @@ -89,4 +89,5 @@ $wb["pm_max_children_error_regex"] = 'PHP-FPM pm.max_children must be a positive $wb["pm_start_servers_error_regex"] = 'PHP-FPM pm.start_servers must be a positive integer value.'; $wb["pm_min_spare_servers_error_regex"] = 'PHP-FPM pm.min_spare_servers must be a positive integer value.'; $wb["pm_max_spare_servers_error_regex"] = 'PHP-FPM pm.max_spare_servers must be a positive integer value.'; +$wb["fastcgi_php_version_txt"] = 'FastCGI PHP Version'; ?> \ No newline at end of file diff --git a/interface/web/sites/templates/web_domain_edit.htm b/interface/web/sites/templates/web_domain_edit.htm index 178c639ed..064cf27e6 100644 --- a/interface/web/sites/templates/web_domain_edit.htm +++ b/interface/web/sites/templates/web_domain_edit.htm @@ -121,6 +121,12 @@ + +
+ +

{tmpl_var name='active_txt'}

@@ -151,6 +157,7 @@ serverId = $(this).val(); adjustForm(); reloadWebIP(); + reloadFastcgiPHPVersions(); }); } adjustForm(); @@ -160,6 +167,14 @@ reloadWebIP(); }); + jQuery('#php').change(function(){ + if(jQuery(this).val() == 'fast-cgi'){ + jQuery('.fastcgi_php_version').show(); + } else { + jQuery('.fastcgi_php_version').hide(); + } + }); + function adjustForm(){ jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) { if(data.servertype == "nginx"){ @@ -184,5 +199,9 @@ loadOptionInto('ip_address','sites/ajax_get_ip.php?ip_type=IPv4&server_id='+serverId+'&client_group_id='+clientGroupId); loadOptionInto('ipv6_address','sites/ajax_get_ip.php?ip_type=IPv6&server_id='+serverId+'&client_group_id='+clientGroupId); } + + function reloadFastcgiPHPVersions() { + loadOptionInto('fastcgi_php_version','sites/ajax_get_fastcgi_php_versions.php?server_id='+serverId+'&client_group_id='+clientGroupId); + } diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index e510bfe52..d861cdb14 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -45,7 +45,7 @@ require_once('../../lib/app.inc.php'); $app->auth->check_module_permissions('sites'); // Loading classes -$app->uses('tpl,tform,tform_actions'); +$app->uses('tpl,tform,tform_actions,ini_parser,getconf'); $app->load('tform_actions'); class page_action extends tform_actions { @@ -128,6 +128,19 @@ class page_action extends tform_actions { $app->tpl->setVar("ipv6_address",$ip_select); unset($tmp); unset($ips); + + //PHP Version Selection (FastCGI) + $fastcgi = $app->getconf->get_server_config($client['default_webserver'],'fastcgi'); + $php_versions = explode('\n',$fastcgi['fastcgi_additional_php_versions']); + $php_select = ""; + if(is_array($php_versions)) { + foreach( $php_versions as $php_version) { + $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; + $php_select .= "\r\n"; + } + } + $app->tpl->setVar("fastcgi_php_version",$php_select); + unset($php_versions); //* Reseller: If the logged in user is not admin and has sub clients (is a reseller) } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { @@ -184,6 +197,19 @@ class page_action extends tform_actions { $app->tpl->setVar("ipv6_address",$ip_select); unset($tmp); unset($ips); + + //PHP Version Selection (FastCGI) + $fastcgi = $app->getconf->get_server_config($client['default_webserver'],'fastcgi'); + $php_versions = explode('\n',$fastcgi['fastcgi_additional_php_versions']); + $php_select = ""; + if(is_array($php_versions)) { + foreach( $php_versions as $php_version) { + $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; + $php_select .= "\r\n"; + } + } + $app->tpl->setVar("fastcgi_php_version",$php_select); + unset($php_versions); //* Admin: If the logged in user is admin } else { @@ -226,6 +252,19 @@ class page_action extends tform_actions { $app->tpl->setVar("ipv6_address",$ip_select); unset($tmp); unset($ips); + + //PHP Version Selection (FastCGI) + $fastcgi = $app->getconf->get_server_config($server_id,'fastcgi'); + $php_versions = explode('\n',$fastcgi['fastcgi_additional_php_versions']); + $php_select = ""; + if(is_array($php_versions)) { + foreach( $php_versions as $php_version) { + $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; + $php_select .= "\r\n"; + } + } + $app->tpl->setVar("fastcgi_php_version",$php_select); + unset($php_versions); // Fill the client select field $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name"; diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index 66940a55d..e9a66c40e 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -909,15 +909,32 @@ class apache2_plugin { $fcgi_tpl = new tpl(); $fcgi_tpl->newTemplate('php-fcgi-starter.master'); + // Support for multiple PHP versions (FastCGI) + if(trim($data['new']['fastcgi_php_version']) != ''){ + $default_fastcgi_php = false; + list($custom_fastcgi_php_name, $custom_fastcgi_php_executable, $custom_fastcgi_php_ini_dir) = explode(';', trim($data['new']['fastcgi_php_version'])); + if(substr($custom_fastcgi_php_ini_dir,-1) != '/') $custom_fastcgi_php_ini_dir .= '/'; + } else { + $default_fastcgi_php = true; + } + if($has_custom_php_ini) { $fcgi_tpl->setVar('php_ini_path',escapeshellcmd($custom_php_ini_dir)); } else { - $fcgi_tpl->setVar('php_ini_path',escapeshellcmd($fastcgi_config['fastcgi_phpini_path'])); + if($default_fastcgi_php){ + $fcgi_tpl->setVar('php_ini_path',escapeshellcmd($fastcgi_config['fastcgi_phpini_path'])); + } else { + $fcgi_tpl->setVar('php_ini_path',escapeshellcmd($custom_fastcgi_php_ini_dir)); + } } $fcgi_tpl->setVar('document_root',escapeshellcmd($data['new']['document_root'])); $fcgi_tpl->setVar('php_fcgi_children',escapeshellcmd($fastcgi_config['fastcgi_children'])); $fcgi_tpl->setVar('php_fcgi_max_requests',escapeshellcmd($fastcgi_config['fastcgi_max_requests'])); - $fcgi_tpl->setVar('php_fcgi_bin',escapeshellcmd($fastcgi_config['fastcgi_bin'])); + if($default_fastcgi_php){ + $fcgi_tpl->setVar('php_fcgi_bin',escapeshellcmd($fastcgi_config['fastcgi_bin'])); + } else { + $fcgi_tpl->setVar('php_fcgi_bin',escapeshellcmd($custom_fastcgi_php_executable)); + } $fcgi_tpl->setVar('security_level',intval($web_config['security_level'])); $php_open_basedir = ($data['new']['php_open_basedir'] == '')?$data['new']['document_root']:$data['new']['php_open_basedir']; -- GitLab