ftimme
2011-09-27 445513c1a26f7f1639fad2f622ce12f7491dfd88
- 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.
1 files added
10 files modified
130 ■■■■ changed files
install/sql/incremental/upd_0025.sql 4 ●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 4 ●●●● patch | view | raw | blame | history
interface/web/sites/form/web_domain.tform.php 48 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/de_web_domain.lng 9 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_domain.lng 9 ●●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_domain_advanced.htm 16 ●●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_edit.php 24 ●●●●● patch | view | raw | blame | history
server/conf/nginx_vhost.conf.master 2 ●●● patch | view | raw | blame | history
server/conf/php_fpm_pool.conf.master 8 ●●●● patch | view | raw | blame | history
server/conf/vhost.conf.master 2 ●●● patch | view | raw | blame | history
server/plugins-available/nginx_plugin.inc.php 4 ●●●● patch | view | raw | blame | history
install/sql/incremental/upd_0025.sql
New file
@@ -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`;
install/sql/ispconfig3.sql
@@ -1513,6 +1513,10 @@
  `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',
interface/web/sites/form/web_domain.tform.php
@@ -511,6 +511,54 @@
            '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',
interface/web/sites/lib/lang/de_web_domain.lng
@@ -80,4 +80,13 @@
$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.';
?>
interface/web/sites/lib/lang/en_web_domain.lng
@@ -80,4 +80,13 @@
$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.';
?>
interface/web/sites/templates/web_domain_advanced.htm
@@ -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;" />
interface/web/sites/web_domain_edit.php
@@ -418,15 +418,23 @@
        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();
    }
server/conf/nginx_vhost.conf.master
@@ -44,7 +44,7 @@
        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>
        
server/conf/php_fpm_pool.conf.master
@@ -15,10 +15,10 @@
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 = /
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
</tmpl_if>
server/plugins-available/nginx_plugin.inc.php
@@ -1132,6 +1132,10 @@
        $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']);