- Implemented: FS#1079 - Custom php.ini files for fcgi and mod_php
- Fixed a formatting problem with suphp.conf and newer suphp versions.
| | |
| | | exec('mkdir -p /var/log/ispconfig/httpd'); |
| | | |
| | | if(is_file('/etc/suphp/suphp.conf')) { |
| | | replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp=php:/usr/bin/php-cgi',0); |
| | | replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp="php:/usr/bin/php-cgi"',0); |
| | | //replaceLine('/etc/suphp/suphp.conf','docroot=','docroot=/var/clients',0); |
| | | replaceLine('/etc/suphp/suphp.conf','umask=0077','umask=0022',0); |
| | | } |
| | |
| | | `allow_override` varchar(255) NOT NULL default 'All', |
| | | `apache_directives` text, |
| | | `php_open_basedir` text, |
| | | `custom_php_ini` text, |
| | | `backup_interval` VARCHAR( 255 ) NOT NULL DEFAULT 'none', |
| | | `backup_copies` INT NOT NULL DEFAULT '1', |
| | | `active` enum('n','y') NOT NULL default 'y', |
| | |
| | | awstats_data_dir=/var/lib/awstats |
| | | awstats_pl=/usr/lib/cgi-bin/awstats.pl |
| | | awstats_buildstaticpages_pl=/usr/share/awstats/tools/awstats_buildstaticpages.pl |
| | | php_ini_path_apache=/etc/php5/apache2/php.ini |
| | | php_ini_path_cgi=/etc/php5/cgi/php.ini |
| | | |
| | | [dns] |
| | | bind_user=root |
| | |
| | | 'width' => '40', |
| | | 'maxlength' => '255' |
| | | ), |
| | | 'php_ini_path_apache' => array ( |
| | | 'datatype' => 'VARCHAR', |
| | | 'formtype' => 'TEXT', |
| | | 'default' => '', |
| | | 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', |
| | | 'errmsg'=> 'php_ini_path_apache_error_empty'), |
| | | ), |
| | | 'value' => '', |
| | | 'width' => '40', |
| | | 'maxlength' => '255' |
| | | ), |
| | | 'php_ini_path_cgi' => array ( |
| | | 'datatype' => 'VARCHAR', |
| | | 'formtype' => 'TEXT', |
| | | 'default' => '', |
| | | 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', |
| | | 'errmsg'=> 'php_ini_path_cgi_error_empty'), |
| | | ), |
| | | 'value' => '', |
| | | 'width' => '40', |
| | | 'maxlength' => '255' |
| | | ), |
| | | 'php_open_basedir' => array ( |
| | | 'datatype' => 'VARCHAR', |
| | | 'formtype' => 'TEXT', |
| | |
| | | $wb["awstats_pl_txt"] = 'awstats.pl script'; |
| | | $wb["awstats_buildstaticpages_pl_txt"] = 'awstats_buildstaticpages.pl script'; |
| | | $wb["backup_dir_txt"] = 'Backup directory'; |
| | | $wb["named_conf_local_path_txt"] = 'BIND named.conf.local path'; |
| | | $wb["php_ini_path_cgi_txt"] = 'CGI php.ini path'; |
| | | $wb["php_ini_path_apache_txt"] = 'Apache php.ini path'; |
| | | ?> |
| | |
| | | <input name="group" id="group" value="{tmpl_var name='group'}" size="40" maxlength="255" type="text" class="textInput" /> |
| | | </div> |
| | | <div class="ctrlHolder"> |
| | | <label for="php_ini_path_apache">{tmpl_var name='php_ini_path_apache_txt'}</label> |
| | | <input name="php_ini_path_apache" id="php_ini_path_apache" value="{tmpl_var name='php_ini_path_apache'}" size="40" maxlength="255" type="text" class="textInput" /> |
| | | </div> |
| | | <div class="ctrlHolder"> |
| | | <label for="php_ini_path_cgi">{tmpl_var name='php_ini_path_cgi_txt'}</label> |
| | | <input name="php_ini_path_cgi" id="php_ini_path_cgi" value="{tmpl_var name='php_ini_path_cgi'}" size="40" maxlength="255" type="text" class="textInput" /> |
| | | </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="40" maxlength="255" type="text" class="textInput" /> |
| | | </div> |
| | |
| | | 'width' => '30', |
| | | 'maxlength' => '255' |
| | | ), |
| | | 'custom_php_ini' => array ( |
| | | 'datatype' => 'TEXT', |
| | | 'formtype' => 'TEXT', |
| | | 'default' => '', |
| | | 'value' => '', |
| | | 'width' => '30', |
| | | 'maxlength' => '255' |
| | | ), |
| | | 'apache_directives' => array ( |
| | | 'datatype' => 'TEXT', |
| | | 'formtype' => 'TEXT', |
| | |
| | | $wb["error_ssl_country_empty"] = 'SSL Country is empty.';
|
| | | $wb["client_group_id_txt"] = 'Client';
|
| | | $wb["stats_password_txt"] = 'Webstatistics password';
|
| | | $wb["allow_override_txt"] = 'Allow Override';
|
| | | $wb["allow_override_txt"] = 'Apache AllowOverride';
|
| | | $wb["limit_web_quota_free_txt"] = 'Max. available Harddisk Quota';
|
| | | $wb["ssl_state_error_regex"] = 'Invalid SSL State. Valid characters are: a-z, 0-9 and .,-_';
|
| | | $wb["ssl_locality_error_regex"] = 'Invalid SSL Locality. Valid characters are: a-z, 0-9 and .,-_';
|
| | |
| | | $wb["ruby_txt"] = 'Ruby';
|
| | | $wb["stats_user_txt"] = 'Webstatistics username';
|
| | | $wb["stats_type_txt"] = 'Webstatistics program';
|
| | | $wb["custom_php_ini_txt"] = 'Custom php.ini settings';
|
| | | ?> |
| | |
| | | </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" maxlength="255" type="text" class="textInput" /> |
| | | <input name="php_open_basedir" id="php_open_basedir" value="{tmpl_var name='php_open_basedir'}" size="30" maxlength="255" type="text" class="textInput" style="width:400px;" /> |
| | | </div> |
| | | <div class="ctrlHolder"> |
| | | <label for="custom_php_ini">{tmpl_var name='custom_php_ini_txt'}</label> |
| | | <textarea name="custom_php_ini" id="custom_php_ini" rows='10' cols='50' style="width:400px;">{tmpl_var name='custom_php_ini'}</textarea> |
| | | </div> |
| | | <div class="ctrlHolder"> |
| | | <label for="apache_directives">{tmpl_var name='apache_directives_txt'}</label> |
| | | <textarea name="apache_directives" id="apache_directives" rows='10' cols='30'>{tmpl_var name='apache_directives'}</textarea> |
| | | </div> |
| | | <textarea name="apache_directives" id="apache_directives" rows='10' cols='50' style="width:400px;">{tmpl_var name='apache_directives'}</textarea> |
| | | </div> |
| | | </fieldset> |
| | | |
| | | <input type="hidden" name="id" value="{tmpl_var name='id'}"> |
| | |
| | | #!/bin/sh |
| | | |
| | | <tmpl_if name='has_custom_php_ini'> |
| | | export PHPRC="<tmpl_var name='php_ini_path'>" |
| | | </tmpl_if> |
| | | |
| | | exec <tmpl_var name='php_cgi_bin'> \ |
| | | -d open_basedir=<tmpl_var name='open_basedir'> \ |
| | | -d upload_tmp_dir=<tmpl_var name='document_root'>/tmp \ |
| | |
| | | php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@<tmpl_var name='domain'>" |
| | | php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp |
| | | php_admin_value session.save_path <tmpl_var name='document_root'>/tmp |
| | | PHPIniDir <tmpl_var name='custom_php_ini_dir'> |
| | | <tmpl_if name='security_level' op='==' value='20'> |
| | | php_admin_value open_basedir <tmpl_var name='php_open_basedir'> |
| | | </tmpl_if> |
| | |
| | | <Directory {tmpl_var name='web_document_root'}> |
| | | suPHP_Engine on |
| | | # suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'> |
| | | <tmpl_if name='has_custom_php_ini'> |
| | | suPHP_ConfigPath <tmpl_var name='custom_php_ini_dir'> |
| | | </tmpl_if> |
| | | AddHandler x-httpd-suphp .php .php3 .php4 .php5 |
| | | suPHP_AddHandler x-httpd-suphp |
| | | </Directory> |
| | |
| | | php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@<tmpl_var name='domain'>" |
| | | php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp |
| | | php_admin_value session.save_path <tmpl_var name='document_root'>/tmp |
| | | PHPIniDir <tmpl_var name='custom_php_ini_dir'> |
| | | <tmpl_if name='security_level' op='==' value='20'> |
| | | php_admin_value open_basedir <tmpl_var name='php_open_basedir'> |
| | | </tmpl_if> |
| | |
| | | <tmpl_if name='php' op='==' value='suphp'> |
| | | suPHP_Engine on |
| | | # suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'> |
| | | <tmpl_if name='has_custom_php_ini'> |
| | | suPHP_ConfigPath <tmpl_var name='custom_php_ini_dir'> |
| | | </tmpl_if> |
| | | AddHandler x-httpd-suphp .php .php3 .php4 .php5 |
| | | suPHP_AddHandler x-httpd-suphp |
| | | </tmpl_if> |
| | |
| | | $this->_exec("chown $username:$groupname ".escapeshellcmd($data["new"]["document_root"])."/log/error.log"); |
| | | |
| | | |
| | | // Create the vhost config file |
| | | //* Write the custom php.ini file, if custom_php_ini filed is not empty |
| | | $custom_php_ini_dir = $web_config['website_basedir'].'/conf/'.$data["new"]["system_user"]; |
| | | if(!is_dir($web_config['website_basedir'].'/conf')) mkdir($web_config['website_basedir'].'/conf'); |
| | | if(trim($data["new"]['custom_php_ini']) != '') { |
| | | $has_custom_php_ini = true; |
| | | if(!is_dir($custom_php_ini_dir)) mkdir($custom_php_ini_dir); |
| | | $php_ini_content = ''; |
| | | if($data["new"]['php'] == 'mod') { |
| | | $master_php_ini_path = $web_config['php_ini_path_apache']; |
| | | } else { |
| | | $master_php_ini_path = $web_config['php_ini_path_cgi']; |
| | | } |
| | | if($master_php_ini_path != '' && substr($master_php_ini_path,-7) == 'php.ini' && is_file($master_php_ini_path)) { |
| | | $php_ini_content .= file_get_contents($master_php_ini_path)."\n"; |
| | | } |
| | | $php_ini_content .= trim($data["new"]['custom_php_ini']); |
| | | file_put_contents($custom_php_ini_dir.'/php.ini',$php_ini_content); |
| | | } else { |
| | | $has_custom_php_ini = false; |
| | | if(is_file($custom_php_ini_dir.'/php.ini')) unlink($custom_php_ini_dir.'/php.ini'); |
| | | } |
| | | |
| | | |
| | | //* Create the vhost config file |
| | | $app->load('tpl'); |
| | | |
| | | $tpl = new tpl(); |
| | |
| | | $vhost_data["allow_override"] = ($data["new"]["allow_override"] == '')?'All':$data["new"]["allow_override"]; |
| | | $vhost_data["php_open_basedir"] = ($data["new"]["php_open_basedir"] == '')?$data["new"]["document_root"]:$data["new"]["php_open_basedir"]; |
| | | $vhost_data["ssl_domain"] = $data["new"]["ssl_domain"]; |
| | | $vhost_data["has_custom_php_ini"] = $has_custom_php_ini; |
| | | $vhost_data["custom_php_ini_dir"] = escapeshellcmd($custom_php_ini_dir); |
| | | |
| | | // Check if a SSL cert exists |
| | | $ssl_dir = $data["new"]["document_root"]."/ssl"; |
| | |
| | | |
| | | $fcgi_tpl = new tpl(); |
| | | $fcgi_tpl->newTemplate("php-fcgi-starter.master"); |
| | | |
| | | $fcgi_tpl->setVar('php_ini_path',escapeshellcmd($fastcgi_config["fastcgi_phpini_path"])); |
| | | |
| | | 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"])); |
| | | } |
| | | $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"])); |
| | |
| | | //$cgi_tpl->setVar('open_basedir', "/var/www/" . $data["new"]["domain"]); |
| | | $cgi_tpl->setVar('php_cgi_bin',$cgi_config["cgi_bin"]); |
| | | $cgi_tpl->setVar('security_level',$web_config["security_level"]); |
| | | |
| | | $cgi_tpl->setVar('has_custom_php_ini',$has_custom_php_ini); |
| | | if($has_custom_php_ini) { |
| | | $cgi_tpl->setVar('php_ini_path',escapeshellcmd($custom_php_ini_dir)); |
| | | } else { |
| | | $cgi_tpl->setVar('php_ini_path',escapeshellcmd($fastcgi_config["fastcgi_phpini_path"])); |
| | | } |
| | | |
| | | $cgi_starter_script = escapeshellcmd($cgi_starter_path.$cgi_config["cgi_starter_script"]); |
| | | file_put_contents($cgi_starter_script,$cgi_tpl->grab()); |