From 445513c1a26f7f1639fad2f622ce12f7491dfd88 Mon Sep 17 00:00:00 2001 From: ftimme Date: Tue, 27 Sep 2011 12:28:22 +0000 Subject: [PATCH] - Added PHP-FPM pm settings (pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers) to the "Options" tab of a website. --- install/sql/incremental/upd_0025.sql | 4 ++ install/sql/ispconfig3.sql | 4 ++ interface/web/sites/form/web_domain.tform.php | 48 +++++++++++++++++++ .../web/sites/lib/lang/de_web_domain.lng | 9 ++++ .../web/sites/lib/lang/en_web_domain.lng | 9 ++++ .../sites/templates/web_domain_advanced.htm | 16 +++++++ interface/web/sites/web_domain_edit.php | 24 ++++++---- server/conf/nginx_vhost.conf.master | 2 +- server/conf/php_fpm_pool.conf.master | 8 ++-- server/conf/vhost.conf.master | 2 +- server/plugins-available/nginx_plugin.inc.php | 4 ++ 11 files changed, 116 insertions(+), 14 deletions(-) create mode 100644 install/sql/incremental/upd_0025.sql diff --git a/install/sql/incremental/upd_0025.sql b/install/sql/incremental/upd_0025.sql new file mode 100644 index 0000000000..c49a971b23 --- /dev/null +++ b/install/sql/incremental/upd_0025.sql @@ -0,0 +1,4 @@ +ALTER TABLE `web_domain` ADD `pm_max_children` INT NOT NULL DEFAULT '50' AFTER `php_fpm_use_socket` , +ADD `pm_start_servers` INT NOT NULL DEFAULT '20' AFTER `pm_max_children` , +ADD `pm_min_spare_servers` INT NOT NULL DEFAULT '5' AFTER `pm_start_servers` , +ADD `pm_max_spare_servers` INT NOT NULL DEFAULT '35' AFTER `pm_min_spare_servers`; \ No newline at end of file diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 378af4a3ed..8a9fad6161 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -1513,6 +1513,10 @@ CREATE TABLE `web_domain` ( `apache_directives` mediumtext, `nginx_directives` mediumtext, `php_fpm_use_socket` ENUM('n','y') NOT NULL DEFAULT 'n', + `pm_max_children` int(11) NOT NULL DEFAULT '50', + `pm_start_servers` int(11) NOT NULL DEFAULT '20', + `pm_min_spare_servers` int(11) NOT NULL DEFAULT '5', + `pm_max_spare_servers` int(11) NOT NULL DEFAULT '35', `php_open_basedir` mediumtext, `custom_php_ini` mediumtext, `backup_interval` VARCHAR( 255 ) NOT NULL DEFAULT 'none', diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php index 43dce0b1b9..4c6bed4e7a 100644 --- a/interface/web/sites/form/web_domain.tform.php +++ b/interface/web/sites/form/web_domain.tform.php @@ -511,6 +511,54 @@ $form["tabs"]['advanced'] = array ( 'default' => 'n', 'value' => array(0 => 'n',1 => 'y') ), + 'pm_max_children' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^([1-9][0-9]{0,10})$/', + 'errmsg'=> 'pm_max_children_error_regex'), + ), + 'default' => '50', + 'value' => '', + 'width' => '3', + 'maxlength' => '3' + ), + 'pm_start_servers' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^([1-9][0-9]{0,10})$/', + 'errmsg'=> 'pm_start_servers_error_regex'), + ), + 'default' => '20', + 'value' => '', + 'width' => '3', + 'maxlength' => '3' + ), + 'pm_min_spare_servers' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^([1-9][0-9]{0,10})$/', + 'errmsg'=> 'pm_min_spare_servers_error_regex'), + ), + 'default' => '5', + 'value' => '', + 'width' => '3', + 'maxlength' => '3' + ), + 'pm_max_spare_servers' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^([1-9][0-9]{0,10})$/', + 'errmsg'=> 'pm_max_spare_servers_error_regex'), + ), + 'default' => '35', + 'value' => '', + 'width' => '3', + 'maxlength' => '3' + ), 'php_open_basedir' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', diff --git a/interface/web/sites/lib/lang/de_web_domain.lng b/interface/web/sites/lib/lang/de_web_domain.lng index b69695a30c..7aec4b17fe 100644 --- a/interface/web/sites/lib/lang/de_web_domain.lng +++ b/interface/web/sites/lib/lang/de_web_domain.lng @@ -80,4 +80,13 @@ $wb['php_fpm_use_socket_txt'] = 'Benutze Socket für PHP-FPM'; $wb['ipv6_address_txt'] = 'IPv6-Address'; $wb['error_no_sni_txt'] = 'SNI for SSL is not activated on this server. You can enable only one SSL certificate on each IP address.'; $wb["python_txt"] = 'Python'; +$wb["pm_max_children_txt"] = 'PHP-FPM pm.max_children'; +$wb["pm_start_servers_txt"] = 'PHP-FPM pm.start_servers'; +$wb["pm_min_spare_servers_txt"] = 'PHP-FPM pm.min_spare_servers'; +$wb["pm_max_spare_servers_txt"] = 'PHP-FPM pm.max_spare_servers'; +$wb["error_php_fpm_pm_settings_txt"] = 'Die Werte der PHP-FPM pm Einstellungen müssen wie folgt sein: pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0'; +$wb["pm_max_children_error_regex"] = 'PHP-FPM pm.max_children muß eine positive ganze Zahl sein.'; +$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.'; ?> diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng index af1e0982d1..b7fcc679f9 100644 --- a/interface/web/sites/lib/lang/en_web_domain.lng +++ b/interface/web/sites/lib/lang/en_web_domain.lng @@ -80,4 +80,13 @@ $wb["www_to_non_www_txt"] = 'www -> non-www'; $wb["php_fpm_use_socket_txt"] = 'Use Socket For PHP-FPM'; $wb["error_no_sni_txt"] = 'SNI for SSL is not activated on this server. You can enable only one SSL certificate on each IP address.'; $wb["python_txt"] = 'Python'; +$wb["pm_max_children_txt"] = 'PHP-FPM pm.max_children'; +$wb["pm_start_servers_txt"] = 'PHP-FPM pm.start_servers'; +$wb["pm_min_spare_servers_txt"] = 'PHP-FPM pm.min_spare_servers'; +$wb["pm_max_spare_servers_txt"] = 'PHP-FPM pm.max_spare_servers'; +$wb["error_php_fpm_pm_settings_txt"] = 'Values of PHP-FPM pm settings must be as follows: pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0'; +$wb["pm_max_children_error_regex"] = 'PHP-FPM pm.max_children must be a positive integer value.'; +$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.'; ?> \ No newline at end of file diff --git a/interface/web/sites/templates/web_domain_advanced.htm b/interface/web/sites/templates/web_domain_advanced.htm index 4b51cc1f62..2000ff6513 100644 --- a/interface/web/sites/templates/web_domain_advanced.htm +++ b/interface/web/sites/templates/web_domain_advanced.htm @@ -26,6 +26,22 @@ {tmpl_var name='php_fpm_use_socket'} +
+ + +
+
+ + +
+
+ + +
+
+ + +
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index 13af0a182f..dff5148ae3 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -418,15 +418,23 @@ class page_action extends tform_actions { if(isset($this->dataRecord["domain"])) $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]); //* get the server config for this server - $app->uses("getconf"); - $web_config = $app->getconf->get_server_config(intval($this->dataRecord["server_id"]),'web'); - //* Check for duplicate ssl certs per IP if SNI is disabled - if(isset($this->dataRecord['ssl']) && $this->dataRecord['ssl'] == 'y' && $web_config['enable_sni'] != 'y') { - $sql = "SELECT count(domain_id) as number FROM web_domain WHERE `ssl` = 'y' AND ip_address = '".$app->db->quote($this->dataRecord['ip_address'])."' and domain_id != ".$this->id; - $tmp = $app->db->queryOneRecord($sql); - if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng("error_no_sni_txt"); - } + $app->uses("getconf"); + $web_config = $app->getconf->get_server_config(intval($this->dataRecord["server_id"]),'web'); + //* Check for duplicate ssl certs per IP if SNI is disabled + if(isset($this->dataRecord['ssl']) && $this->dataRecord['ssl'] == 'y' && $web_config['enable_sni'] != 'y') { + $sql = "SELECT count(domain_id) as number FROM web_domain WHERE `ssl` = 'y' AND ip_address = '".$app->db->quote($this->dataRecord['ip_address'])."' and domain_id != ".$this->id; + $tmp = $app->db->queryOneRecord($sql); + if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng("error_no_sni_txt"); + } + + // Check if pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0 + if(isset($this->dataRecord['pm_max_children'])) { + if(intval($this->dataRecord['pm_max_children']) >= intval($this->dataRecord['pm_max_spare_servers']) && intval($this->dataRecord['pm_max_spare_servers']) >= intval($this->dataRecord['pm_start_servers']) && intval($this->dataRecord['pm_start_servers']) >= intval($this->dataRecord['pm_min_spare_servers']) && intval($this->dataRecord['pm_min_spare_servers']) > 0){ + } else { + $app->tform->errorMessage .= $app->tform->lng("error_php_fpm_pm_settings_txt").'
'; + } + } parent::onSubmit(); } diff --git a/server/conf/nginx_vhost.conf.master b/server/conf/nginx_vhost.conf.master index fd057311b0..4027b56377 100644 --- a/server/conf/nginx_vhost.conf.master +++ b/server/conf/nginx_vhost.conf.master @@ -44,7 +44,7 @@ server { error_page 404 /error/404.html; error_page 405 /error/405.html; error_page 500 /error/500.html; - error_page 502 /error/502.html; + error_page 502 /error/502.html; error_page 503 /error/503.html; diff --git a/server/conf/php_fpm_pool.conf.master b/server/conf/php_fpm_pool.conf.master index 0e741734f1..cd1ba125ac 100644 --- a/server/conf/php_fpm_pool.conf.master +++ b/server/conf/php_fpm_pool.conf.master @@ -15,10 +15,10 @@ user = group = pm = dynamic -pm.max_children = 50 -pm.start_servers = 20 -pm.min_spare_servers = 5 -pm.max_spare_servers = 35 +pm.max_children = +pm.start_servers = +pm.min_spare_servers = +pm.max_spare_servers = chdir = / diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master index 8ea14b7f12..410d44d9c5 100644 --- a/server/conf/vhost.conf.master +++ b/server/conf/vhost.conf.master @@ -33,7 +33,7 @@ ErrorDocument 404 /error/404.html ErrorDocument 405 /error/405.html ErrorDocument 500 /error/500.html - ErrorDocument 502 /error/502.html + ErrorDocument 502 /error/502.html ErrorDocument 503 /error/503.html diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 4c9c2abfae..5e927cdecb 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -1132,6 +1132,10 @@ class nginx_plugin { $tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id'] + 1); $tpl->setVar('fpm_user', $data['new']['system_user']); $tpl->setVar('fpm_group', $data['new']['system_group']); + $tpl->setVar('pm_max_children', $data['new']['pm_max_children']); + $tpl->setVar('pm_start_servers', $data['new']['pm_start_servers']); + $tpl->setVar('pm_min_spare_servers', $data['new']['pm_min_spare_servers']); + $tpl->setVar('pm_max_spare_servers', $data['new']['pm_max_spare_servers']); $tpl->setVar('document_root', $data['new']['document_root']); $tpl->setVar('security_level',$web_config['security_level']); $php_open_basedir = ($data['new']['php_open_basedir'] == '')?escapeshellcmd($data['new']['document_root']):escapeshellcmd($data['new']['php_open_basedir']); -- GitLab