From 62b385fcdae1fbbad37548626f48ed8c33db9ba9 Mon Sep 17 00:00:00 2001 From: ftimme <ft@falkotimme.com> Date: Tue, 06 Mar 2012 14:42:09 -0500 Subject: [PATCH] - Added support for multiple PHP versions (Apache + PHP-FastCGI). --- interface/web/sites/lib/lang/de_web_domain.lng | 1 interface/web/admin/templates/server_config_fastcgi_edit.htm | 4 + interface/web/sites/lib/lang/en_web_domain.lng | 1 interface/web/admin/lib/lang/en_server_config.lng | 2 interface/web/sites/web_domain_edit.php | 41 +++++++++++++ install/tpl/server.ini.master | 1 interface/web/admin/form/server_config.tform.php | 8 ++ install/sql/incremental/upd_0031.sql | 1 interface/web/admin/lib/lang/de_server_config.lng | 2 install/sql/ispconfig3.sql | 1 server/plugins-available/apache2_plugin.inc.php | 21 ++++++ interface/web/sites/form/web_domain.tform.php | 11 +++ interface/web/sites/ajax_get_fastcgi_php_versions.php | 58 +++++++++++++++++++ interface/web/sites/templates/web_domain_edit.htm | 19 ++++++ 14 files changed, 168 insertions(+), 3 deletions(-) diff --git a/install/sql/incremental/upd_0031.sql b/install/sql/incremental/upd_0031.sql new file mode 100644 index 0000000..f14e126 --- /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 8055d82..a755adf 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -1549,6 +1549,7 @@ `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 275fa7a..9f6f30c 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -90,6 +90,7 @@ 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 24f3f18..facc193 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -867,6 +867,14 @@ '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 fd78f1b..7911e94 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['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:<br><name>;<path_to_executable>;<path_to_php.ini_dir><br>z.B.:<br>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 4cce275..c6a80f2 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_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:<br><name>;<path_to_executable>;<path_to_php.ini_dir><br>e.g.:<br>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 3ca49c5..0f051f5 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'} </select> </div> + <div class="ctrlHolder"> + <label for="fastcgi_additional_php_versions">{tmpl_var name='fastcgi_additional_php_versions_txt'}</label> + <textarea rows="10" cols="40" name="fastcgi_additional_php_versions" id="fastcgi_additional_php_versions" type="text" class="textInput">{tmpl_var name='fastcgi_additional_php_versions'}</textarea> {tmpl_var name='fastcgi_additional_php_versions_hint_txt'} + </div> </fieldset> <input type="hidden" name="id" value="{tmpl_var name='id'}"> 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 0000000..41d2536 --- /dev/null +++ b/interface/web/sites/ajax_get_fastcgi_php_versions.php @@ -0,0 +1,58 @@ +<?php + +/* +Copyright (c) 2005, Till Brehm, projektfarm Gmbh +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +require_once('../../lib/config.inc.php'); +require_once('../../lib/app.inc.php'); + +//* Check permissions for module +$app->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 af05cdf..5e79c19 100644 --- a/interface/web/sites/form/web_domain.tform.php +++ b/interface/web/sites/form/web_domain.tform.php @@ -210,6 +210,17 @@ '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 2cfebf2..27a74ba 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_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 b7fcc67..bd6becf 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_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 178c639..064cf27 100644 --- a/interface/web/sites/templates/web_domain_edit.htm +++ b/interface/web/sites/templates/web_domain_edit.htm @@ -122,6 +122,12 @@ {tmpl_var name='php'} </select> </div> + <div class="ctrlHolder fastcgi_php_version"> + <label for="fastcgi_php_version">{tmpl_var name='fastcgi_php_version_txt'}</label> + <select name="fastcgi_php_version" id="fastcgi_php_version" class="selectInput formLengthHalf"> + {tmpl_var name='fastcgi_php_version'} + </select> + </div> <div class="ctrlHolder"> <p class="label">{tmpl_var name='active_txt'}</p> <div class="multiField"> @@ -151,6 +157,7 @@ serverId = $(this).val(); adjustForm(); reloadWebIP(); + reloadFastcgiPHPVersions(); }); } adjustForm(); @@ -158,6 +165,14 @@ jQuery('#client_group_id').change(function(){ clientGroupId = $(this).val(); reloadWebIP(); + }); + + jQuery('#php').change(function(){ + if(jQuery(this).val() == 'fast-cgi'){ + jQuery('.fastcgi_php_version').show(); + } else { + jQuery('.fastcgi_php_version').hide(); + } }); function adjustForm(){ @@ -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); + } </script> diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index e510bfe..d861cdb 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -45,7 +45,7 @@ $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 @@ $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 = "<option value=''>Default</option>"; + if(is_array($php_versions)) { + foreach( $php_versions as $php_version) { + $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; + $php_select .= "<option value='$php_version' $selected>$php_version</option>\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 @@ $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 = "<option value=''>Default</option>"; + if(is_array($php_versions)) { + foreach( $php_versions as $php_version) { + $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; + $php_select .= "<option value='$php_version' $selected>$php_version</option>\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 @@ $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 = "<option value=''>Default</option>"; + if(is_array($php_versions)) { + foreach( $php_versions as $php_version) { + $selected = ($php_version == $this->dataRecord["fastcgi_php_version"])?'SELECTED':''; + $php_select .= "<option value='$php_version' $selected>$php_version</option>\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 66940a5..e9a66c4 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -909,15 +909,32 @@ $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']; -- Gitblit v1.9.1