Commit 445513c1 authored by Falko Timme's avatar Falko Timme

- Added PHP-FPM pm settings (pm.max_children, pm.start_servers,...

- 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.
parent ced7398e
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
......@@ -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',
......
......@@ -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',
......
......@@ -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.';
?>
......@@ -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
......@@ -26,6 +26,22 @@
{tmpl_var name='php_fpm_use_socket'}
</div>
</div>
<div class="ctrlHolder nginx">
<label for="pm_max_children">{tmpl_var name='pm_max_children_txt'}</label>
<input name="pm_max_children" id="pm_max_children" value="{tmpl_var name='pm_max_children'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder nginx">
<label for="pm_start_servers">{tmpl_var name='pm_start_servers_txt'}</label>
<input name="pm_start_servers" id="pm_start_servers" value="{tmpl_var name='pm_start_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder nginx">
<label for="pm_min_spare_servers">{tmpl_var name='pm_min_spare_servers_txt'}</label>
<input name="pm_min_spare_servers" id="pm_min_spare_servers" value="{tmpl_var name='pm_min_spare_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder nginx">
<label for="pm_max_spare_servers">{tmpl_var name='pm_max_spare_servers_txt'}</label>
<input name="pm_max_spare_servers" id="pm_max_spare_servers" value="{tmpl_var name='pm_max_spare_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder">
<label for="php_open_basedir">{tmpl_var name='php_open_basedir_txt'}</label>
<input name="php_open_basedir" id="php_open_basedir" value="{tmpl_var name='php_open_basedir'}" size="30" type="text" class="textInput" style="width:400px;" />
......
......@@ -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").'<br>';
}
}
parent::onSubmit();
}
......
......@@ -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;
</tmpl_if>
......
......@@ -15,10 +15,10 @@ user = <tmpl_var name='fpm_user'>
group = <tmpl_var name='fpm_group'>
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_children = <tmpl_var name='pm_max_children'>
pm.start_servers = <tmpl_var name='pm_start_servers'>
pm.min_spare_servers = <tmpl_var name='pm_min_spare_servers'>
pm.max_spare_servers = <tmpl_var name='pm_max_spare_servers'>
chdir = /
......
......@@ -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
</tmpl_if>
......
......@@ -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']);
......
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