Merge pull request #17 from blackice2999/fixes-php-fpm-rewrite

Fixes php fpm rewrite, fixes #1089, thx blackice2999
This commit is contained in:
Florian Aders
2012-05-22 23:36:20 -07:00
8 changed files with 129 additions and 81 deletions

View File

@@ -56,7 +56,7 @@ return array(
), ),
/* /*
* @TODO implement if phpfpm knows custom php.ini files * @TODO implement if phpfpm knows custom php.ini files
* *
'system_phpfpm_defaultini_ownvhost' => array( 'system_phpfpm_defaultini_ownvhost' => array(
'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'], 'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',
@@ -77,6 +77,15 @@ return array(
'default' => '/etc/php-fpm.d/', 'default' => '/etc/php-fpm.d/',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
), ),
'system_phpfpm_aliasconfigdir' => array(
'label' => $lng['serversettings']['phpfpm_settings']['aliasconfigdir'],
'settinggroup' => 'phpfpm',
'varname' => 'aliasconfigdir',
'type' => 'string',
'string_type' => 'dir',
'default' => '/var/www/php-fpm/',
'save_method' => 'storeSettingField',
),
'system_phpfpm_tmpdir' => array( 'system_phpfpm_tmpdir' => array(
'label' => $lng['serversettings']['mod_fcgid']['tmpdir'], 'label' => $lng['serversettings']['mod_fcgid']['tmpdir'],
'settinggroup' => 'phpfpm', 'settinggroup' => 'phpfpm',

View File

@@ -1642,7 +1642,7 @@ if(isFroxlorVersion('0.9.22-svn1'))
/* fix backup_dir for #186 */ /* fix backup_dir for #186 */
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/var/customers/backups/' WHERE `varname` = 'backup_dir';"); $db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/var/customers/backups/' WHERE `varname` = 'backup_dir';");
updateToVersion('0.9.22-svn2'); updateToVersion('0.9.22-svn2');
} }
@@ -1650,7 +1650,7 @@ if(isFroxlorVersion('0.9.22-svn2'))
{ {
showUpdateStep("Updating from 0.9.22-svn2 to 0.9.22-rc1"); showUpdateStep("Updating from 0.9.22-svn2 to 0.9.22-rc1");
lastStepStatus(0); lastStepStatus(0);
updateToVersion('0.9.22-rc1'); updateToVersion('0.9.22-rc1');
} }
@@ -1658,7 +1658,7 @@ if(isFroxlorVersion('0.9.22-rc1'))
{ {
showUpdateStep("Updating from 0.9.22-rc1 to 0.9.22"); showUpdateStep("Updating from 0.9.22-rc1 to 0.9.22");
lastStepStatus(0); lastStepStatus(0);
updateToVersion('0.9.22'); updateToVersion('0.9.22');
} }
@@ -1729,10 +1729,10 @@ if(isFroxlorVersion('0.9.25'))
{ {
showUpdateStep("Updating from 0.9.25 to 0.9.26-svn1"); showUpdateStep("Updating from 0.9.25 to 0.9.26-svn1");
lastStepStatus(0); lastStepStatus(0);
// enable bind by default // enable bind by default
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bind_enable', '1')"); $db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bind_enable', '1')");
updateToVersion('0.9.26-svn1'); updateToVersion('0.9.26-svn1');
} }
@@ -1756,24 +1756,24 @@ if(isFroxlorVersion('0.9.26'))
{ {
showUpdateStep("Updating from 0.9.26 to 0.9.27-svn1"); showUpdateStep("Updating from 0.9.26 to 0.9.27-svn1");
lastStepStatus(0); lastStepStatus(0);
// check for multiple backup_ftp_enabled entries // check for multiple backup_ftp_enabled entries
$handle = $db->query("SELECT `value` FROM `panel_settings` WHERE `varname` = 'backup_ftp_enabled';"); $handle = $db->query("SELECT `value` FROM `panel_settings` WHERE `varname` = 'backup_ftp_enabled';");
// if there are more than one entry try to fix it // if there are more than one entry try to fix it
if ($db->num_rows($handle) > 1) { if ($db->num_rows($handle) > 1) {
$rows = $db->fetch_array($handle); $rows = $db->fetch_array($handle);
$state = false; $state = false;
// iterate through all found entries // iterate through all found entries
// and try to guess what value it should be // and try to guess what value it should be
foreach ($rows as $row) { foreach ($rows as $row) {
$state = $state | $row['value']; $state = $state | $row['value'];
} }
// now delete all entries // now delete all entries
$db->query("DELETE FROM `panel_settings` WHERE `varname` = 'backup_ftp_enabled';"); $db->query("DELETE FROM `panel_settings` WHERE `varname` = 'backup_ftp_enabled';");
// and re-add it // and re-add it
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_enabled', '". $state ."');"); $db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_enabled', '". $state ."');");
} }
@@ -1785,18 +1785,18 @@ if(isFroxlorVersion('0.9.27-svn1'))
{ {
showUpdateStep("Updating from 0.9.27-svn1 to 0.9.27-svn2"); showUpdateStep("Updating from 0.9.27-svn1 to 0.9.27-svn2");
lastStepStatus(0); lastStepStatus(0);
// Get FastCGI timeout setting if available // Get FastCGI timeout setting if available
$handle = $db->query("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'system' AND `varname` = 'mod_fcgid_idle_timeout';"); $handle = $db->query("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'system' AND `varname` = 'mod_fcgid_idle_timeout';");
// If timeout is set then skip // If timeout is set then skip
if ($db->num_rows($handle) < 1) { if ($db->num_rows($handle) < 1) {
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'mod_fcgid_idle_timeout', '30');"); $db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'mod_fcgid_idle_timeout', '30');");
} }
// Get FastCGI timeout setting if available // Get FastCGI timeout setting if available
$handle = $db->query("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'phpfpm' AND `varname` = 'idle_timeout';"); $handle = $db->query("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'phpfpm' AND `varname` = 'idle_timeout';");
// If timeout is set then skip // If timeout is set then skip
if ($db->num_rows($handle) < 1) { if ($db->num_rows($handle) < 1) {
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'idle_timeout', '30');"); $db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'idle_timeout', '30');");
@@ -1821,3 +1821,17 @@ if(isFroxlorVersion('0.9.27-rc1'))
updateToVersion('0.9.27'); updateToVersion('0.9.27');
} }
if(isFroxlorVersion('0.9.27')) {
showUpdateStep("Updating from 0.9.27 to 0.9.28-fpmfix");
lastStepStatus(0);
// Get AliasconfigDir setting if available
$handle = $db->query("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'phpfpm' AND `varname` = 'aliasconfigdir';");
// If AliasconfigDir is set then skip
if ($db->num_rows($handle) < 1) {
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'aliasconfigdir', '/var/www/php-fpm/');");
}
updateToVersion('0.9.28-fpmfix');
}

View File

@@ -125,13 +125,13 @@ class phpinterface_fpm
{ {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd); $_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
} }
$_custom_openbasedir = explode(':', $this->_settings['system']['phpappendopenbasedir']); $_custom_openbasedir = explode(':', $this->_settings['system']['phpappendopenbasedir']);
foreach($_custom_openbasedir as $cobd) foreach($_custom_openbasedir as $cobd)
{ {
$_phpappendopenbasedir .= appendOpenBasedirPath($cobd); $_phpappendopenbasedir .= appendOpenBasedirPath($cobd);
} }
if($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false) if($this->_domain['openbasedir_path'] == '0' && strstr($this->_domain['documentroot'], ":") === false)
{ {
$openbasedir = appendOpenBasedirPath($this->_domain['documentroot'], true); $openbasedir = appendOpenBasedirPath($this->_domain['documentroot'], true);
@@ -140,10 +140,10 @@ class phpinterface_fpm
{ {
$openbasedir = appendOpenBasedirPath($this->_domain['customerroot'], true); $openbasedir = appendOpenBasedirPath($this->_domain['customerroot'], true);
} }
$openbasedir .= appendOpenBasedirPath($this->getTempDir()); $openbasedir .= appendOpenBasedirPath($this->getTempDir());
$openbasedir .= $_phpappendopenbasedir; $openbasedir .= $_phpappendopenbasedir;
$openbasedir = explode(':', $openbasedir); $openbasedir = explode(':', $openbasedir);
$clean_openbasedir = array(); $clean_openbasedir = array();
foreach($openbasedir as $number => $path) foreach($openbasedir as $number => $path)
@@ -229,7 +229,31 @@ class phpinterface_fpm
safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir)); safe_exec('chown -R ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($tmpdir));
safe_exec('chmod 0750 ' . escapeshellarg($tmpdir)); safe_exec('chmod 0750 ' . escapeshellarg($tmpdir));
} }
return $tmpdir; return $tmpdir;
} }
/**
* fastcgi-fakedirectory directory
*
* @param boolean $createifnotexists create the directory if it does not exist
*
* @return string the directory
*/
public function getAliasConfigDir($createifnotexists = true)
{
// ensure default...
if (!isset($this->_settings['phpfpm']['aliasconfigdir'])) {
$this->_settings['phpfpm']['aliasconfigdir'] = '/var/www/php-fpm';
}
$configdir = makeCorrectDir($this->_settings['phpfpm']['aliasconfigdir'] . '/' . $this->_domain['loginname'] . '/' . $this->_domain['domain'] . '/');
if(!is_dir($configdir) && $createifnotexists)
{
safe_exec('mkdir -p ' . escapeshellarg($configdir));
safe_exec('chown ' . $this->_domain['guid'] . ':' . $this->_domain['guid'] . ' ' . escapeshellarg($configdir));
}
return $configdir;
}
} }

View File

@@ -37,7 +37,7 @@ function processForm(&$form, &$input, $url_params = array())
} }
} }
} }
foreach($form['groups'] as $groupname => $groupdetails) foreach($form['groups'] as $groupname => $groupdetails)
{ {
if(validateFieldDefinition($groupdetails)) if(validateFieldDefinition($groupdetails))
@@ -46,7 +46,7 @@ function processForm(&$form, &$input, $url_params = array())
foreach($groupdetails['fields'] as $fieldname => $fielddetails) foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{ {
$newfieldvalue = getFormFieldData($fieldname, $fielddetails, $input); $newfieldvalue = getFormFieldData($fieldname, $fielddetails, $input);
if($newfieldvalue != $fielddetails['value']) if($newfieldvalue != $fielddetails['value'])
{ {
if(($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true) if(($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true)
@@ -173,13 +173,13 @@ function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_
} }
} }
} }
foreach($form['groups'] as $groupname => $groupdetails) foreach($form['groups'] as $groupname => $groupdetails)
{ {
if(($settings_part && $part == $groupname) if(($settings_part && $part == $groupname)
|| $settings_all || $settings_all
|| $only_enabledisable || $only_enabledisable
){ ){
if(validateFieldDefinition($groupdetails)) if(validateFieldDefinition($groupdetails))
{ {
// Validate fields // Validate fields
@@ -189,7 +189,6 @@ function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_
|| ($only_enabledisable && isset($fielddetails['overview_option'])) || ($only_enabledisable && isset($fielddetails['overview_option']))
) { ) {
$newfieldvalue = getFormFieldData($fieldname, $fielddetails, $input); $newfieldvalue = getFormFieldData($fieldname, $fielddetails, $input);
if($newfieldvalue != $fielddetails['value']) if($newfieldvalue != $fielddetails['value'])
{ {
if(($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true) if(($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true)
@@ -201,7 +200,7 @@ function processFormEx(&$form, &$input, $url_params = array(), $part, $settings_
$changed_fields[$fieldname] = $newfieldvalue; $changed_fields[$fieldname] = $newfieldvalue;
} }
} }
$submitted_fields[$fieldname] = $newfieldvalue; $submitted_fields[$fieldname] = $newfieldvalue;
} }
} }

View File

@@ -21,6 +21,7 @@ function storeSettingField($fieldname, $fielddata, $newfieldvalue)
{ {
if(is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] != '' && isset($fielddata['varname']) && $fielddata['varname'] != '') if(is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] != '' && isset($fielddata['varname']) && $fielddata['varname'] != '')
{ {
if(saveSetting($fielddata['settinggroup'], $fielddata['varname'], $newfieldvalue) != false) if(saveSetting($fielddata['settinggroup'], $fielddata['varname'], $newfieldvalue) != false)
{ {
/* /*
@@ -30,7 +31,7 @@ function storeSettingField($fieldname, $fielddata, $newfieldvalue)
{ {
toggleCronStatus($fielddata['cronmodule'], $newfieldvalue); toggleCronStatus($fielddata['cronmodule'], $newfieldvalue);
} }
/* /*
* satisfy dependencies * satisfy dependencies
*/ */
@@ -47,7 +48,7 @@ function storeSettingField($fieldname, $fielddata, $newfieldvalue)
else else
{ {
return false; return false;
} }
} }
else else
{ {
@@ -66,7 +67,7 @@ function storeSettingFieldInsertBindTask($fieldname, $fielddata, $newfieldvalue)
else else
{ {
return false; return false;
} }
} }
else else
{ {

View File

@@ -1527,6 +1527,7 @@ $lng['error']['intvaluetoohigh'] = 'The given number is too high (field %s)';
$lng['admin']['phpfpm_settings'] = 'PHP-FPM'; $lng['admin']['phpfpm_settings'] = 'PHP-FPM';
$lng['serversettings']['phpfpm'] = 'Enable php-fpm'; $lng['serversettings']['phpfpm'] = 'Enable php-fpm';
$lng['serversettings']['phpfpm_settings']['configdir'] = 'Configuration directory of php-fpm'; $lng['serversettings']['phpfpm_settings']['configdir'] = 'Configuration directory of php-fpm';
$lng['serversettings']['phpfpm_settings']['aliasconfigdir'] = 'Configuration Alias-directory of php-fpm';
$lng['serversettings']['phpfpm_settings']['reload'] = 'php-fpm restart command'; $lng['serversettings']['phpfpm_settings']['reload'] = 'php-fpm restart command';
$lng['serversettings']['phpfpm_settings']['pm'] = 'Process manager control (pm)'; $lng['serversettings']['phpfpm_settings']['pm'] = 'Process manager control (pm)';
$lng['serversettings']['phpfpm_settings']['max_children']['title'] = 'The number of child processes'; $lng['serversettings']['phpfpm_settings']['max_children']['title'] = 'The number of child processes';

View File

@@ -30,21 +30,21 @@ class apache
private $logger = false; private $logger = false;
private $debugHandler = false; private $debugHandler = false;
private $idnaConvert = false; private $idnaConvert = false;
// protected // protected
protected $settings = array(); protected $settings = array();
protected $known_vhostfilenames = array(); protected $known_vhostfilenames = array();
protected $known_diroptionsfilenames = array(); protected $known_diroptionsfilenames = array();
protected $known_htpasswdsfilenames = array(); protected $known_htpasswdsfilenames = array();
protected $virtualhosts_data = array(); protected $virtualhosts_data = array();
protected $diroptions_data = array(); protected $diroptions_data = array();
protected $htpasswds_data = array(); protected $htpasswds_data = array();
/** /**
* indicator whether a customer is deactivated or not * indicator whether a customer is deactivated or not
* if yes, only the webroot will be generated * if yes, only the webroot will be generated
* *
* @var bool * @var bool
*/ */
private $_deactivated = false; private $_deactivated = false;
@@ -57,7 +57,7 @@ class apache
$this->idnaConvert = $idnaConvert; $this->idnaConvert = $idnaConvert;
$this->settings = $settings; $this->settings = $settings;
} }
protected function getDB() protected function getDB()
{ {
return $this->db; return $this->db;
@@ -75,7 +75,7 @@ class apache
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading apache'); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading apache');
safe_exec(escapeshellcmd($this->settings['system']['apachereload_command'])); safe_exec(escapeshellcmd($this->settings['system']['apachereload_command']));
} }
/** /**
* define a standard <Directory>-statement, bug #32 * define a standard <Directory>-statement, bug #32
*/ */
@@ -99,7 +99,7 @@ class apache
fwrite($this->debugHandler, ' apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename) . "\n"); fwrite($this->debugHandler, ' apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename) . "\n");
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'unlinking ' . basename($vhosts_filename)); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'unlinking ' . basename($vhosts_filename));
unlink(makeCorrectFile($vhosts_filename)); unlink(makeCorrectFile($vhosts_filename));
} }
} }
else else
{ {
@@ -133,14 +133,14 @@ class apache
} else { } else {
$vhosts_folder = makeCorrectDir(dirname($this->settings['system']['apacheconf_vhost'])); $vhosts_folder = makeCorrectDir(dirname($this->settings['system']['apacheconf_vhost']));
} }
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_default_errorhandler.conf'); $vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_default_errorhandler.conf');
if(!isset($this->virtualhosts_data[$vhosts_filename])) if(!isset($this->virtualhosts_data[$vhosts_filename]))
{ {
$this->virtualhosts_data[$vhosts_filename] = ''; $this->virtualhosts_data[$vhosts_filename] = '';
} }
if($this->settings['defaultwebsrverrhandler']['err401'] != '') if($this->settings['defaultwebsrverrhandler']['err401'] != '')
{ {
$this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 401 ' . $this->settings['defaultwebsrverrhandler']['err401'] . "\n"; $this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 401 ' . $this->settings['defaultwebsrverrhandler']['err401'] . "\n";
@@ -155,7 +155,7 @@ class apache
{ {
$this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 404 ' . $this->settings['defaultwebsrverrhandler']['err404'] . "\n"; $this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 404 ' . $this->settings['defaultwebsrverrhandler']['err404'] . "\n";
} }
if($this->settings['defaultwebsrverrhandler']['err500'] != '') if($this->settings['defaultwebsrverrhandler']['err500'] != '')
{ {
$this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 500 ' . $this->settings['defaultwebsrverrhandler']['err500'] . "\n"; $this->virtualhosts_data[$vhosts_filename].= 'ErrorDocument 500 ' . $this->settings['defaultwebsrverrhandler']['err500'] . "\n";
@@ -213,7 +213,7 @@ class apache
{ {
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
} }
else else
{ {
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__))))); $mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
} }
@@ -225,7 +225,7 @@ class apache
} }
$this->virtualhosts_data[$vhosts_filename].= 'DocumentRoot "'.$mypath.'"'."\n"; $this->virtualhosts_data[$vhosts_filename].= 'DocumentRoot "'.$mypath.'"'."\n";
if($row_ipsandports['vhostcontainer_servername_statement'] == '1') if($row_ipsandports['vhostcontainer_servername_statement'] == '1')
{ {
$this->virtualhosts_data[$vhosts_filename].= ' ServerName ' . $this->settings['system']['hostname'] . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' ServerName ' . $this->settings['system']['hostname'] . "\n";
@@ -236,7 +236,7 @@ class apache
&& $this->settings['system']['mod_fcgid'] == '1' && $this->settings['system']['mod_fcgid'] == '1'
) )
{ {
$configdir = makeCorrectDir($this->settings['system']['mod_fcgid_configdir'] . '/froxlor.panel/' . $this->settings['system']['hostname']); $configdir = makeCorrectDir($this->settings['system']['mod_fcgid_configdir'] . '/froxlor.panel/' . $this->settings['system']['hostname']);
$this->virtualhosts_data[$vhosts_filename].= ' FcgidIdleTimeout ' . $this->settings['system']['mod_fcgid_idle_timeout'] . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' FcgidIdleTimeout ' . $this->settings['system']['mod_fcgid_idle_timeout'] . "\n";
if((int)$this->settings['system']['mod_fcgid_wrapper'] == 0) if((int)$this->settings['system']['mod_fcgid_wrapper'] == 0)
@@ -271,12 +271,12 @@ class apache
'safemode' => '0', 'safemode' => '0',
'email' => $this->settings['panel']['adminmail'], 'email' => $this->settings['panel']['adminmail'],
'loginname' => 'froxlor.panel', 'loginname' => 'froxlor.panel',
'documentroot' => $mypath 'documentroot' => $mypath,
); );
$php = new phpinterface($this->getDB(), $this->settings, $domain); $php = new phpinterface($this->getDB(), $this->settings, $domain);
$this->virtualhosts_data[$vhosts_filename].= ' SuexecUserGroup "' . $this->settings['system']['mod_fcgid_httpuser'] . '" "' . $this->settings['system']['mod_fcgid_httpgroup'] . '"' . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' SuexecUserGroup "' . $this->settings['system']['mod_fcgid_httpuser'] . '" "' . $this->settings['system']['mod_fcgid_httpgroup'] . '"' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' FastCgiExternalServer ' . $mypath . $domain['domain'] . "." . 'fpm.external -socket ' . $php->getInterface()->getSocketFile() . ' -user ' . $this->settings['system']['mod_fcgid_httpuser'] . ' -group ' . $this->settings['system']['mod_fcgid_httpuser'] . " -idle-timeout " . $this->settings['phpfpm']['idle_timeout'] . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . 'fpm.external -socket ' . $php->getInterface()->getSocketFile() . ' -user ' . $this->settings['system']['mod_fcgid_httpuser'] . ' -group ' . $this->settings['system']['mod_fcgid_httpuser'] . " -idle-timeout " . $this->settings['phpfpm']['idle_timeout'] . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' <Directory "' . $mypath . '">' . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' <Directory "' . $mypath . '">' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' AddHandler php5-fastcgi .php'. "\n"; $this->virtualhosts_data[$vhosts_filename].= ' AddHandler php5-fastcgi .php'. "\n";
$this->virtualhosts_data[$vhosts_filename].= ' Action php5-fastcgi /fastcgiphp' . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' Action php5-fastcgi /fastcgiphp' . "\n";
@@ -284,7 +284,7 @@ class apache
$this->virtualhosts_data[$vhosts_filename].= ' Order allow,deny' . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' Order allow,deny' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' allow from all' . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' allow from all' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' </Directory>' . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' </Directory>' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' Alias /fastcgiphp ' . $mypath . $domain['domain'] . "." . 'fpm.external' . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' Alias /fastcgiphp ' . $php->getInterface()->getAliasConfigDir() . 'fpm.external' . "\n";
} }
/** /**
@@ -294,7 +294,7 @@ class apache
$this->virtualhosts_data[$vhosts_filename].= "\t\tAllow from all\n"; $this->virtualhosts_data[$vhosts_filename].= "\t\tAllow from all\n";
$this->virtualhosts_data[$vhosts_filename].= "\t\tOptions -Indexes\n"; $this->virtualhosts_data[$vhosts_filename].= "\t\tOptions -Indexes\n";
$this->virtualhosts_data[$vhosts_filename].= "\t</Directory>\n"; $this->virtualhosts_data[$vhosts_filename].= "\t</Directory>\n";
$this->virtualhosts_data[$vhosts_filename].= "\t<Directory \"'.$mypath.'*\">\n"; $this->virtualhosts_data[$vhosts_filename].= "\t<Directory \"'.$mypath.'*\">\n";
$this->virtualhosts_data[$vhosts_filename].= "\t\tOrder Deny,Allow\n"; $this->virtualhosts_data[$vhosts_filename].= "\t\tOrder Deny,Allow\n";
$this->virtualhosts_data[$vhosts_filename].= "\t\tDeny from All\n"; $this->virtualhosts_data[$vhosts_filename].= "\t\tDeny from All\n";
@@ -334,12 +334,12 @@ class apache
{ {
$this->virtualhosts_data[$vhosts_filename].= ' SSLEngine On' . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' SSLEngine On' . "\n";
$this->virtualhosts_data[$vhosts_filename].= ' SSLCertificateFile ' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' SSLCertificateFile ' . makeCorrectFile($row_ipsandports['ssl_cert_file']) . "\n";
if($row_ipsandports['ssl_key_file'] != '') if($row_ipsandports['ssl_key_file'] != '')
{ {
$this->virtualhosts_data[$vhosts_filename].= ' SSLCertificateKeyFile ' . makeCorrectFile($row_ipsandports['ssl_key_file']) . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' SSLCertificateKeyFile ' . makeCorrectFile($row_ipsandports['ssl_key_file']) . "\n";
} }
if($row_ipsandports['ssl_ca_file'] != '') if($row_ipsandports['ssl_ca_file'] != '')
{ {
$this->virtualhosts_data[$vhosts_filename].= ' SSLCACertificateFile ' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . "\n"; $this->virtualhosts_data[$vhosts_filename].= ' SSLCACertificateFile ' . makeCorrectFile($row_ipsandports['ssl_ca_file']) . "\n";
@@ -358,7 +358,7 @@ class apache
} }
unset($vhosts_filename); unset($vhosts_filename);
} }
/** /**
* bug #32 * bug #32
*/ */
@@ -392,7 +392,7 @@ class apache
{ {
$_phpappendopenbasedir = appendOpenBasedirPath($domain['documentroot'], true); $_phpappendopenbasedir = appendOpenBasedirPath($domain['documentroot'], true);
} }
$_custom_openbasedir = explode(':', $this->settings['system']['phpappendopenbasedir']); $_custom_openbasedir = explode(':', $this->settings['system']['phpappendopenbasedir']);
foreach($_custom_openbasedir as $cobd) foreach($_custom_openbasedir as $cobd)
{ {
@@ -419,7 +419,7 @@ class apache
return $php_options_text; return $php_options_text;
} }
public function createOwnVhostStarter() public function createOwnVhostStarter()
{ {
} }
@@ -525,7 +525,7 @@ class apache
} }
else else
{ {
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']) . '"' . "\n"; $stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']) . '"' . "\n";
} }
} }
else else
@@ -549,7 +549,7 @@ class apache
{ {
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']) . '"' . "\n"; $stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n"; $stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
} }
else else
{ {
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n"; $stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n";
@@ -609,13 +609,13 @@ class apache
touch($error_log); touch($error_log);
chown($error_log, $this->settings['system']['httpuser']); chown($error_log, $this->settings['system']['httpuser']);
chgrp($error_log, $this->settings['system']['httpgroup']); chgrp($error_log, $this->settings['system']['httpgroup']);
$access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log'); $access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log');
// Create the logfile if it does not exist (fixes #46) // Create the logfile if it does not exist (fixes #46)
touch($access_log); touch($access_log);
chown($access_log, $this->settings['system']['httpuser']); chown($access_log, $this->settings['system']['httpuser']);
chgrp($access_log, $this->settings['system']['httpgroup']); chgrp($access_log, $this->settings['system']['httpgroup']);
$logfiles_text.= ' ErrorLog "' . $error_log . "\"\n"; $logfiles_text.= ' ErrorLog "' . $error_log . "\"\n";
$logfiles_text.= ' CustomLog "' . $access_log .'" combined' . "\n"; $logfiles_text.= ' CustomLog "' . $access_log .'" combined' . "\n";
@@ -623,19 +623,19 @@ class apache
if($this->settings['system']['awstats_enabled'] == '1') if($this->settings['system']['awstats_enabled'] == '1')
{ {
if((int)$domain['parentdomainid'] == 0) if((int)$domain['parentdomainid'] == 0)
{ {
// prepare the aliases and subdomains for stats config files // prepare the aliases and subdomains for stats config files
$server_alias = ''; $server_alias = '';
$alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '` $alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '`
WHERE `aliasdomain`=\'' . $domain['id'] . '\' WHERE `aliasdomain`=\'' . $domain['id'] . '\'
OR `parentdomainid` =\''. $domain['id']. '\''); OR `parentdomainid` =\''. $domain['id']. '\'');
while(($alias_domain = $this->db->fetch_array($alias_domains)) !== false) while(($alias_domain = $this->db->fetch_array($alias_domains)) !== false)
{ {
$server_alias.= ' ' . $alias_domain['domain'] . ' '; $server_alias.= ' ' . $alias_domain['domain'] . ' ';
if($alias_domain['iswildcarddomain'] == '1') if($alias_domain['iswildcarddomain'] == '1')
{ {
$server_alias.= '*.' . $alias_domain['domain']; $server_alias.= '*.' . $alias_domain['domain'];
@@ -652,7 +652,7 @@ class apache
} }
} }
} }
if($domain['iswildcarddomain'] == '1') if($domain['iswildcarddomain'] == '1')
{ {
$alias = '*.' . $domain['domain']; $alias = '*.' . $domain['domain'];
@@ -668,8 +668,8 @@ class apache
$alias = ''; $alias = '';
} }
} }
// After inserting the AWStats information, // After inserting the AWStats information,
// be sure to build the awstats conf file as well // be sure to build the awstats conf file as well
// and chown it using $awstats_params, #258 // and chown it using $awstats_params, #258
// Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations // Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations
@@ -686,14 +686,14 @@ class apache
protected function getVhostFilename($domain, $ssl_vhost = false) protected function getVhostFilename($domain, $ssl_vhost = false)
{ {
if((int)$domain['parentdomainid'] == 0 if((int)$domain['parentdomainid'] == 0
&& isCustomerStdSubdomain((int)$domain['id']) == false && isCustomerStdSubdomain((int)$domain['id']) == false
&& ((int)$domain['ismainbutsubto'] == 0 && ((int)$domain['ismainbutsubto'] == 0
|| domainMainToSubExists($domain['ismainbutsubto']) == false) || domainMainToSubExists($domain['ismainbutsubto']) == false)
) { ) {
$vhost_no = '22'; $vhost_no = '22';
} }
elseif((int)$domain['parentdomainid'] == 0 elseif((int)$domain['parentdomainid'] == 0
&& isCustomerStdSubdomain((int)$domain['id']) == false && isCustomerStdSubdomain((int)$domain['id']) == false
&& (int)$domain['ismainbutsubto'] > 0 && (int)$domain['ismainbutsubto'] > 0
) { ) {
@@ -772,14 +772,14 @@ class apache
if(substr($corrected_docroot, -1) == '/') { if(substr($corrected_docroot, -1) == '/') {
$corrected_docroot = substr($corrected_docroot, 0, -1); $corrected_docroot = substr($corrected_docroot, 0, -1);
} }
/* Get domain's redirect code */ /* Get domain's redirect code */
$code = getDomainRedirectCode($domain['id']); $code = getDomainRedirectCode($domain['id']);
$modrew_red = ''; $modrew_red = '';
if ($code != '') { if ($code != '') {
$modrew_red = '[R='. $code . ';L]'; $modrew_red = '[R='. $code . ';L]';
} }
// redirect everything, not only root-directory, #541 // redirect everything, not only root-directory, #541
$vhost_content.= ' <IfModule mod_rewrite.c>'."\n"; $vhost_content.= ' <IfModule mod_rewrite.c>'."\n";
$vhost_content.= ' RewriteEngine On' . "\n"; $vhost_content.= ' RewriteEngine On' . "\n";
@@ -1308,10 +1308,10 @@ class apache
foreach($this->known_vhostfilenames as $vhostfilename){ foreach($this->known_vhostfilenames as $vhostfilename){
$known_phpfpm_files[]=preg_replace('/^(05|10|20|21|22|30|50|51)_(froxlor|syscp)_(dirfix|ipandport|normal_vhost|wildcard_vhost|ssl_vhost)_/', '', $vhostfilename); $known_phpfpm_files[]=preg_replace('/^(05|10|20|21|22|30|50|51)_(froxlor|syscp)_(dirfix|ipandport|normal_vhost|wildcard_vhost|ssl_vhost)_/', '', $vhostfilename);
} }
$configdir = $this->settings['phpfpm']['configdir']; $configdir = $this->settings['phpfpm']['configdir'];
$phpfpm_file_dirhandle = opendir($this->settings['phpfpm']['configdir']); $phpfpm_file_dirhandle = opendir($this->settings['phpfpm']['configdir']);
while(false !== ($phpfpm_filename = readdir($phpfpm_file_dirhandle))) while(false !== ($phpfpm_filename = readdir($phpfpm_file_dirhandle)))
{ {
if($phpfpm_filename != '.' if($phpfpm_filename != '.'
@@ -1364,10 +1364,10 @@ class apache
foreach($this->known_vhostfilenames as $vhostfilename){ foreach($this->known_vhostfilenames as $vhostfilename){
$known_phpfpm_files[]=preg_replace('/^(05|10|20|21|22|30|50|51)_(froxlor|syscp)_(dirfix|ipandport|normal_vhost|wildcard_vhost|ssl_vhost)_/', '', $vhostfilename); $known_phpfpm_files[]=preg_replace('/^(05|10|20|21|22|30|50|51)_(froxlor|syscp)_(dirfix|ipandport|normal_vhost|wildcard_vhost|ssl_vhost)_/', '', $vhostfilename);
} }
$configdir = $this->settings['phpfpm']['configdir']; $configdir = $this->settings['phpfpm']['configdir'];
$phpfpm_file_dirhandle = opendir($this->settings['phpfpm']['configdir']); $phpfpm_file_dirhandle = opendir($this->settings['phpfpm']['configdir']);
while(false !== ($phpfpm_filename = readdir($phpfpm_file_dirhandle))) while(false !== ($phpfpm_filename = readdir($phpfpm_file_dirhandle)))
{ {
if(is_array($known_phpfpm_files) if(is_array($known_phpfpm_files)
@@ -1404,7 +1404,7 @@ class apache
while(false !== ($htpasswd_filename = readdir($htpasswds_file_dirhandle))) while(false !== ($htpasswd_filename = readdir($htpasswds_file_dirhandle)))
{ {
if($htpasswd_filename != '.' if($htpasswd_filename != '.'
&& $htpasswd_filename != '..' && $htpasswd_filename != '..'
&& !in_array($htpasswd_filename, $this->known_htpasswdsfilenames) && !in_array($htpasswd_filename, $this->known_htpasswdsfilenames)
&& file_exists(makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $htpasswd_filename))) && file_exists(makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $htpasswd_filename)))
{ {

View File

@@ -38,7 +38,7 @@ class apache_fcgid extends apache
if((int)$this->settings['phpfpm']['enabled'] == 1) if((int)$this->settings['phpfpm']['enabled'] == 1)
{ {
$php_options_text.= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n"; $php_options_text.= ' SuexecUserGroup "' . $domain['loginname'] . '" "' . $domain['loginname'] . '"' . "\n";
$php_options_text.= ' FastCgiExternalServer ' . makeCorrectDir($domain['documentroot']) . $domain['domain'] . "." . 'fpm.external -socket ' . $php->getInterface()->getSocketFile() . ' -user ' . $domain['loginname'] . ' -group ' . $domain['loginname'] . " -idle-timeout " . $this->settings['phpfpm']['idle_timeout'] . "\n"; $php_options_text.= ' FastCgiExternalServer ' . makeCorrectDir($php->getInterface()->getAliasConfigDir()) . 'fpm.external -socket ' . $php->getInterface()->getSocketFile() . ' -user ' . $domain['loginname'] . ' -group ' . $domain['loginname'] . " -idle-timeout " . $this->settings['phpfpm']['idle_timeout'] . "\n";
$php_options_text.= ' <Directory "' . makeCorrectDir($domain['documentroot']) . '">' . "\n"; $php_options_text.= ' <Directory "' . makeCorrectDir($domain['documentroot']) . '">' . "\n";
$php_options_text.= ' <FilesMatch "\.php$">' . "\n"; $php_options_text.= ' <FilesMatch "\.php$">' . "\n";
$php_options_text.= ' SetHandler php5-fastcgi'. "\n"; $php_options_text.= ' SetHandler php5-fastcgi'. "\n";
@@ -48,7 +48,7 @@ class apache_fcgid extends apache
$php_options_text.= ' Order allow,deny' . "\n"; $php_options_text.= ' Order allow,deny' . "\n";
$php_options_text.= ' allow from all' . "\n"; $php_options_text.= ' allow from all' . "\n";
$php_options_text.= ' </Directory>' . "\n"; $php_options_text.= ' </Directory>' . "\n";
$php_options_text.= ' Alias /fastcgiphp ' . makeCorrectDir($domain['documentroot']) . $domain['domain'] . "." . 'fpm.external' . "\n"; $php_options_text.= ' Alias /fastcgiphp ' . makeCorrectDir($php->getInterface()->getAliasConfigDir()) . 'fpm.external' . "\n";
} }
else else
{ {
@@ -79,8 +79,8 @@ class apache_fcgid extends apache
// create starter-file | config-file // create starter-file | config-file
$php->getInterface()->createConfig($phpconfig); $php->getInterface()->createConfig($phpconfig);
// create php.ini // create php.ini
// @TODO make php-fpm support this // @TODO make php-fpm support this
$php->getInterface()->createIniFile($phpconfig); $php->getInterface()->createIniFile($phpconfig);
} }
@@ -109,7 +109,7 @@ class apache_fcgid extends apache
&& $this->settings['phpfpm']['enabled_ownvhost'] == '1' && $this->settings['phpfpm']['enabled_ownvhost'] == '1'
) { ) {
$user = $this->settings['phpfpm']['vhost_httpuser']; $user = $this->settings['phpfpm']['vhost_httpuser'];
$group = $this->settings['phpfpm']['vhost_httpgroup']; $group = $this->settings['phpfpm']['vhost_httpgroup'];
} }
$domain = array( $domain = array(
@@ -129,7 +129,7 @@ class apache_fcgid extends apache
// all the files and folders have to belong to the local user // all the files and folders have to belong to the local user
// now because we also use fcgid for our own vhost // now because we also use fcgid for our own vhost
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath)); safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
// get php.ini for our own vhost // get php.ini for our own vhost
$php = new phpinterface($this->getDB(), $this->settings, $domain); $php = new phpinterface($this->getDB(), $this->settings, $domain);
@@ -138,8 +138,8 @@ class apache_fcgid extends apache
// create starter-file | config-file // create starter-file | config-file
$php->getInterface()->createConfig($phpconfig); $php->getInterface()->createConfig($phpconfig);
// create php.ini // create php.ini
// @TODO make php-fpm support this // @TODO make php-fpm support this
$php->getInterface()->createIniFile($phpconfig); $php->getInterface()->createIniFile($phpconfig);
} }