diff --git a/actions/admin/settings/136.phpfpm.php b/actions/admin/settings/136.phpfpm.php index d8de4fd1..589f42f1 100644 --- a/actions/admin/settings/136.phpfpm.php +++ b/actions/admin/settings/136.phpfpm.php @@ -29,7 +29,45 @@ return array( 'save_method' => 'storeSettingField', 'plausibility_check_method' => 'checkFcgidPhpFpm', 'overview_option' => true - ), + ), + 'system_phpfpm_enabled_ownvhost' => array( + 'label' => $lng['serversettings']['phpfpm'], + 'settinggroup' => 'phpfpm', + 'varname' => 'enabled_ownvhost', + 'type' => 'bool', + 'default' => false, + 'save_method' => 'storeSettingField' + ), + 'system_phpfpm_httpuser' => array( + 'label' => $lng['admin']['mod_fcgid_user'], + 'settinggroup' => 'phpfpm', + 'varname' => 'vhost_httpuser', + 'type' => 'string', + 'default' => 'froxlorlocal', + 'save_method' => 'storeSettingField' + ), + 'system_phpfpm_httpgroup' => array( + 'label' => $lng['admin']['mod_fcgid_group'], + 'settinggroup' => 'phpfpm', + 'varname' => 'vhost_httpgroup', + 'type' => 'string', + 'default' => 'froxlorlocal', + 'save_method' => 'storeSettingField' + ), + /* + * @TODO implement if phpfpm knows custom php.ini files + * + 'system_phpfpm_defaultini_ownvhost' => array( + 'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'], + 'settinggroup' => 'phpfpm', + 'varname' => 'vhost_defaultini', + 'type' => 'option', + 'default' => '1', + 'option_mode' => 'one', + 'option_options_method' => 'getPhpConfigs', + 'save_method' => 'storeSettingField', + ), + */ 'system_phpfpm_configdir' => array( 'label' => $lng['serversettings']['phpfpm_settings']['configdir'], 'settinggroup' => 'phpfpm', diff --git a/install/froxlor.sql b/install/froxlor.sql index 87bea846..c8470f1f 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -462,7 +462,7 @@ INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) V INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (18, 'system', 'vmail_homedir', '/var/customers/mail/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (19, 'system', 'bindconf_directory', '/etc/bind/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (20, 'system', 'bindreload_command', '/etc/init.d/bind9 reload'); -INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '0.9.16-svn1'); +INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '0.9.16-svn2'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (23, 'system', 'hostname', 'SERVERNAME'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (24, 'login', 'maxloginattempts', '3'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (25, 'login', 'deactivatetime', '900'); @@ -608,6 +608,9 @@ INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) V INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (167, 'phpfpm', 'max_requests', '0'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (168, 'phpfpm', 'tmpdir', '/var/customers/tmp/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (169, 'phpfpm', 'peardir', '/usr/share/php/:/usr/share/php5/'); +INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (170, 'phpfpm', 'enabled_ownvhost', '0'); +INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (171, 'phpfpm', 'vhost_httpuser', 'froxlorlocal'); +INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (172, 'phpfpm', 'vhost_httpgroup', 'froxlorlocal'); # -------------------------------------------------------- diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index 43aa5c81..bf722be2 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -937,7 +937,7 @@ if(isFroxlorVersion('0.9.11')) $update_fcgid_ownvhost = isset($_POST['update_fcgid_ownvhost']) ? (int)$_POST['update_fcgid_ownvhost'] : '0'; $update_fcgid_httpuser = isset($_POST['update_fcgid_httpuser']) ? $_POST['update_fcgid_httpuser'] : 'froxlorlocal'; - $update_fcgid_httpgroup = isset($_POST['update_fcgid_ownvhost']) ? $_POST['update_fcgid_ownvhost'] : 'froxlorlocal'; + $update_fcgid_httpgroup = isset($_POST['update_fcgid_httpgroup']) ? $_POST['update_fcgid_httpgroup'] : 'froxlorlocal'; if($update_fcgid_httpuser == '') { $update_fcgid_httpuser = 'froxlorlocal'; @@ -1305,7 +1305,7 @@ if(isFroxlorVersion('0.9.15')) $update_phpfpm_reload = '/etc/init.d/php-fpm restart'; } - showUpdateStep("Adding new settings"); + showUpdateStep("Adding new settings for PHP-FPM #1"); $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'enabled', '".(int)$update_phpfpm_enabled."');"); $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'configdir', '".$db->escape($update_phpfpm_configdir)."');"); $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'reload', '".$db->escape($update_phpfpm_reload)."');"); @@ -1321,3 +1321,27 @@ if(isFroxlorVersion('0.9.15')) updateToVersion('0.9.16-svn1'); } + +if(isFroxlorVersion('0.9.16-svn1')) +{ + showUpdateStep("Updating from 0.9.16-svn1 to 0.9.16-svn2", false); + + $update_phpfpm_enabled_ownvhost = isset($_POST['update_phpfpm_enabled_ownvhost']) ? (int)$_POST['update_phpfpm_enabled_ownvhost'] : '0'; + $update_phpfpm_httpuser = isset($_POST['update_phpfpm_httpuser']) ? $_POST['update_phpfpm_httpuser'] : 'froxlorlocal'; + $update_phpfpm_httpgroup = isset($_POST['update_phpfpm_httpgroup']) ? $_POST['update_phpfpm_httpgroup'] : 'froxlorlocal'; + + if($update_phpfpm_httpuser == '') { + $update_phpfpm_httpuser = 'froxlorlocal'; + } + if($update_phpfpm_httpgroup == '') { + $update_phpfpm_httpgroup = 'froxlorlocal'; + } + + showUpdateStep("Adding new settings for PHP-FPM #2"); + $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'enabled_ownvhost', '".(int)$update_phpfpm_enabled_ownvhost."');"); + $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'vhost_httpuser', '".$db->escape($update_phpfpm_httpuser)."');"); + $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('phpfpm', 'vhost_httpgroup', '".$db->escape($update_phpfpm_httpgroup)."');"); + lastStepStatus(0); + + updateToVersion('0.9.16-svn2'); +} diff --git a/install/updates/preconfig/0.9/preconfig_0.9.inc.php b/install/updates/preconfig/0.9/preconfig_0.9.inc.php index 6ce1bdfb..37ff8de5 100644 --- a/install/updates/preconfig/0.9/preconfig_0.9.inc.php +++ b/install/updates/preconfig/0.9/preconfig_0.9.inc.php @@ -251,7 +251,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) $question.= 'Local user: '; $question.= '

'; $question.= 'Local group: '; - $question.= '
'; + $question.= '
'; eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); } } @@ -384,4 +384,21 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) $question.= '
'; eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); } + + if(versionInUpdate($current_version, '0.9.16-svn2')) + { + if((int)$settings['phpfpm']['enabled'] == 1) + { + $has_preconfig = true; + $description = 'You can chose whether you want Froxlor to use PHP-FPM itself too now.'; + $question = 'Use PHP-FPM for the Froxlor Panel?: '; + $question.= makeyesno('update_phpfpm_enabled_ownvhost', '1', '0', '0').'

'; + $question.= 'If \'yes\', please specify local user/group (have to exist, Froxlor does not add them automatically):

'; + $question.= 'Local user: '; + $question.= '

'; + $question.= 'Local group: '; + $question.= '
'; + eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); + } + } } diff --git a/lib/navigation/00.froxlor.main.php b/lib/navigation/00.froxlor.main.php index c0e3b74f..a9e08637 100644 --- a/lib/navigation/00.froxlor.main.php +++ b/lib/navigation/00.froxlor.main.php @@ -218,7 +218,14 @@ return array ( array ( 'url' => 'admin_phpsettings.php?page=overview', 'label' => $lng['menue']['phpsettings']['maintitle'], - 'show_element' => ( getSetting('system', 'mod_fcgid') == true ), + 'show_element' => ( + getSetting('system', 'mod_fcgid') == true + /* + * @TODO activate if phpfpm knows custom php.ini files + * + * || getSetting('phpfpm', 'enabled') == true + */ + ), ), ), ), diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index 8d6fed13..7e1197e3 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -246,6 +246,35 @@ class apache $this->virtualhosts_data[$vhosts_filename].= ' ' . "\n"; } } + // create php-fpm -Part (config is created in apache_fcgid) + elseif($this->settings['phpfpm']['enabled'] == '1') + { + $domain = array( + 'id' => 'none', + 'domain' => $this->settings['system']['hostname'], + 'adminid' => 1, /* first admin-user (superadmin) */ + 'mod_fcgid_starter' => -1, + 'mod_fcgid_maxrequests' => -1, + 'guid' => $this->settings['phpfpm']['vhost_httpuser'], + 'openbasedir' => 0, + 'safemode' => '0', + 'email' => $this->settings['panel']['adminmail'], + 'loginname' => 'froxlor.panel', + 'documentroot' => $mypath + ); + + $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].= ' FastCgiExternalServer ' . $mypath . 'fpm.external -socket ' . $php->getInterface()->getSocketFile() . ' -user ' . $this->settings['system']['mod_fcgid_httpuser'] . ' -group ' . $this->settings['system']['mod_fcgid_httpuser'] . "\n"; + $this->virtualhosts_data[$vhosts_filename].= ' ' . "\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].= ' Options +ExecCGI' . "\n"; + $this->virtualhosts_data[$vhosts_filename].= ' Order allow,deny' . "\n"; + $this->virtualhosts_data[$vhosts_filename].= ' allow from all' . "\n"; + $this->virtualhosts_data[$vhosts_filename].= ' ' . "\n"; + $this->virtualhosts_data[$vhosts_filename].= ' Alias /fastcgiphp ' . $mypath . 'fpm.external' . "\n"; + } /** * dirprotection, see #72 diff --git a/scripts/jobs/cron_tasks.inc.http.15.apache_fcgid.php b/scripts/jobs/cron_tasks.inc.http.15.apache_fcgid.php index 239cdd02..2d6937b8 100644 --- a/scripts/jobs/cron_tasks.inc.http.15.apache_fcgid.php +++ b/scripts/jobs/cron_tasks.inc.http.15.apache_fcgid.php @@ -89,114 +89,54 @@ class apache_fcgid extends apache public function createOwnVhostStarter() { - if ($this->settings['system']['mod_fcgid_ownvhost'] == '1') - { + if ($this->settings['system']['mod_fcgid_ownvhost'] == '1' + || ($this->settings['phpfpm']['enabled'] == '1' + && $this->settings['phpfpm']['enabled_ownvhost'] == '1') + ) { $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); // /var/www/froxlor, needed for chown - $configdir = makeCorrectDir($this->settings['system']['mod_fcgid_configdir'] . '/froxlor.panel/'); - $starter_filename = makeCorrectFile($configdir . '/php-fcgi-starter'); - $phpini_filename = makeCorrectFile($configdir . '/php.ini'); - $tmpdir = makeCorrectDir($this->settings['system']['mod_fcgid_tmpdir'] . '/froxlor.panel/'); - - $user = $this->settings['system']['mod_fcgid_httpuser']; - $group = $this->settings['system']['mod_fcgid_httpgroup']; + + if ($this->settings['system']['mod_fcgid_ownvhost'] == '1') + { + $user = $this->settings['system']['mod_fcgid_httpuser']; + $group = $this->settings['system']['mod_fcgid_httpgroup']; + } + elseif($this->settings['phpfpm']['enabled'] == '1' + && $this->settings['phpfpm']['enabled_ownvhost'] == '1' + ) { + $user = $this->settings['phpfpm']['vhost_httpuser']; + $group = $this->settings['phpfpm']['vhost_httpgroup']; + } + + $domain = array( + 'id' => 'none', + 'domain' => $this->settings['system']['hostname'], + 'adminid' => 1, /* first admin-user (superadmin) */ + 'mod_fcgid_starter' => -1, + 'mod_fcgid_maxrequests' => -1, + 'guid' => $user, + 'openbasedir' => 0, + 'safemode' => '0', + 'email' => $this->settings['panel']['adminmail'], + 'loginname' => 'froxlor.panel', + 'documentroot' => $mypath + ); // all the files and folders have to belong to the local user // now because we also use fcgid for our own vhost safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath)); - - // create config dir if necessary - if(!is_dir($configdir)) - { - safe_exec('mkdir -p ' . escapeshellarg($configdir)); - safe_exec('chown ' . $user . ':' . $group . ' ' . escapeshellarg($configdir)); - } - - // create tmp dir if necessary - if(!is_dir($tmpdir)) - { - safe_exec('mkdir -p ' . escapeshellarg($tmpdir)); - safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($tmpdir)); - safe_exec('chmod 0750 ' . escapeshellarg($tmpdir)); - } - + // get php.ini for our own vhost - $php = new phpinterface($this->getDB(), $this->settings, null); + $php = new phpinterface($this->getDB(), $this->settings, $domain); + + // @FIXME don't use fcgid settings if not fcgid in use, but we don't have anything else atm $phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']); - // create starter - $starter_file = "#!/bin/sh\n\n"; - $starter_file.= "#\n"; - $starter_file.= "# starter created/changed on " . date("Y.m.d H:i:s") . " for the Froxlor vhost\n"; - $starter_file.= "# Do not change anything in this file, it will be overwritten by the Froxlor Cronjob!\n"; - $starter_file.= "#\n\n"; - $starter_file.= "umask 022\n"; - $starter_file.= "PHPRC=" . escapeshellarg($configdir) . "\n"; - $starter_file.= "export PHPRC\n"; - if((int)$phpconfig['mod_fcgid_starter'] != - 1) - { - $starter_file.= "PHP_FCGI_CHILDREN=" . (int)$phpconfig['mod_fcgid_starter'] . "\n"; - } - else - { - $starter_file.= "PHP_FCGI_CHILDREN=" . (int)$this->settings['system']['mod_fcgid_starter'] . "\n"; - } - $starter_file.= "export PHP_FCGI_CHILDREN\n"; - if((int)$phpconfig['mod_fcgid_maxrequests'] != - 1) - { - $starter_file.= "PHP_FCGI_MAX_REQUESTS=" . (int)$phpconfig['mod_fcgid_maxrequests'] . "\n"; - } - else - { - $starter_file.= "PHP_FCGI_MAX_REQUESTS=" . (int)$this->settings['system']['mod_fcgid_maxrequests'] . "\n"; - } - $starter_file.= "export PHP_FCGI_MAX_REQUESTS\n"; - - // Set Binary - $starter_file.= "exec " . $phpconfig['binary'] . " -c " . escapeshellarg($configdir) . "\n"; - - //remove +i attibute, so starter can be overwritten - if(file_exists($starter_filename)) - { - removeImmutable($starter_filename); - } - - $starter_file_handler = fopen($starter_filename, 'w'); - fwrite($starter_file_handler, $starter_file); - fclose($starter_file_handler); - safe_exec('chmod 750 ' . escapeshellarg($starter_filename)); - safe_exec('chown ' . $user . ':' . $group . ' ' . escapeshellarg($starter_filename)); - setImmutable($starter_filename); - - // define the php.ini - - $php_ini_variables = array( - 'SAFE_MODE' => 'Off', - 'PEAR_DIR' => $this->settings['system']['mod_fcgid_peardir'], - 'OPEN_BASEDIR' => 'none', - 'OPEN_BASEDIR_C' => ';', - 'OPEN_BASEDIR_GLOBAL' => '', - 'TMP_DIR' => $tmpdir, - 'CUSTOMER_EMAIL' => $this->settings['panel']['adminmail'], - 'ADMIN_EMAIL' => $this->settings['panel']['adminmail'], - 'DOMAIN' => $this->settings['system']['hostname'], - 'CUSTOMER' => $user, - 'ADMIN' => $user - ); - - //insert a small header for the file - - $phpini_file = ";\n"; - $phpini_file.= "; php.ini created/changed on " . date("Y.m.d H:i:s") . " for Froxlor-vhost from php template '" . $phpconfig['description'] . "' with id #" . $phpconfig['id'] . "\n"; - $phpini_file.= "; Do not change anything in this file, it will be overwritten by the Froxlor Cronjob!\n"; - $phpini_file.= ";\n\n"; - $phpini_file.= replace_variables($phpconfig['phpsettings'], $php_ini_variables); - $phpini_file = str_replace('"none"', 'none', $phpini_file); - $phpini_file = preg_replace('/\"+/', '"', $phpini_file); - $phpini_file_handler = fopen($phpini_filename, 'w'); - fwrite($phpini_file_handler, $phpini_file); - fclose($phpini_file_handler); - safe_exec('chown root:0 ' . escapeshellarg($phpini_filename)); - safe_exec('chmod 0644 ' . escapeshellarg($phpini_filename)); + // create starter-file | config-file + $php->getInterface()->createConfig($phpconfig); + + // create php.ini + // @TODO make php-fpm support this + $php->getInterface()->createIniFile($phpconfig); } } } diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index f6e78457..4374639d 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -144,6 +144,38 @@ class lighttpd $this->lighttpd_data[$vhost_filename].= ' }' . "\n"; */ + /** + * own php-fpm vhost + */ + if((int)$this->settings['phpfpm']['enabled'] == 1) + { + $domain = array( + 'id' => 'none', + 'domain' => $this->settings['system']['hostname'], + 'adminid' => 1, /* first admin-user (superadmin) */ + 'mod_fcgid_starter' => -1, + 'mod_fcgid_maxrequests' => -1, + 'guid' => $this->settings['phpfpm']['vhost_httpuser'], + 'openbasedir' => 0, + 'safemode' => '0', + 'email' => $this->settings['panel']['adminmail'], + 'loginname' => 'froxlor.panel', + 'documentroot' => $mypath + ); + + $php = new phpinterface($this->getDB(), $this->settings, $domain); + + $this->lighttpd_data[$vhost_filename].= ' fastcgi.server = ( '."\n"; + $this->lighttpd_data[$vhost_filename].= "\t".'".php" => ('."\n"; + $this->lighttpd_data[$vhost_filename].= "\t\t".'"localhost" => ('."\n"; + $this->lighttpd_data[$vhost_filename].= "\t\t".'"socket" => "'.$php->getInterface()->getSocketFile().'",'."\n"; + $this->lighttpd_data[$vhost_filename].= "\t\t".'"check-local" => "enable",'."\n"; + $this->lighttpd_data[$vhost_filename].= "\t\t".'"disable-time" => 1'."\n"; + $this->lighttpd_data[$vhost_filename].= "\t".')'."\n"; + $this->lighttpd_data[$vhost_filename].= "\t".')'."\n"; + $this->lighttpd_data[$vhost_filename].= ' )'."\n"; + } + if($row_ipsandports['specialsettings'] != '') { $this->lighttpd_data[$vhost_filename].= $row_ipsandports['specialsettings'] . "\n"; diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index 94f704a5..566a318c 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -228,8 +228,30 @@ class nginx $this->nginx_data[$vhost_filename].= "\t".'location ~ \.php$ {'."\n"; $this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_index index.php;'."\n"; $this->nginx_data[$vhost_filename].= "\t\t".'include /etc/nginx/fastcgi_params;'."\n"; - $this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root' . '$fastcgi_script_name;'."\n"; - $this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n"; + $this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n"; + if((int)$this->settings['phpfpm']['enabled'] == 1) + { + $domain = array( + 'id' => 'none', + 'domain' => $this->settings['system']['hostname'], + 'adminid' => 1, /* first admin-user (superadmin) */ + 'mod_fcgid_starter' => -1, + 'mod_fcgid_maxrequests' => -1, + 'guid' => $this->settings['phpfpm']['vhost_httpuser'], + 'openbasedir' => 0, + 'safemode' => '0', + 'email' => $this->settings['panel']['adminmail'], + 'loginname' => 'froxlor.panel', + 'documentroot' => $mypath + ); + + $php = new phpinterface($this->getDB(), $this->settings, $domain); + $this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n"; + } + else + { + $this->nginx_data[$vhost_filename].= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n"; + } $this->nginx_data[$vhost_filename].= "\t".'}'."\n"; $this->nginx_data[$vhost_filename].= '}' . "\n\n"; @@ -539,7 +561,7 @@ class nginx $phpopts = "\t".'location ~ \.php$ {'."\n"; $phpopts.= "\t\t".'fastcgi_index index.php;'."\n"; $phpopts.= "\t\t".'include /etc/nginx/fastcgi_params;'."\n"; - $phpopts.= "\t\t".'fastcgi_param SCRIPT_FILENAME '.makeCorrectDir($domain['documentroot']).'$fastcgi_script_name;'."\n"; + $phpopts.= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n"; $phpopts.= "\t\t".'fastcgi_pass ' . $this->settings['system']['nginx_php_backend'] . ';' . "\n"; $phpopts.= "\t".'}'."\n"; } diff --git a/scripts/jobs/cron_tasks.inc.http.35.nginx_phpfpm.php b/scripts/jobs/cron_tasks.inc.http.35.nginx_phpfpm.php index 41edbf2c..a5a6eacd 100644 --- a/scripts/jobs/cron_tasks.inc.http.35.nginx_phpfpm.php +++ b/scripts/jobs/cron_tasks.inc.http.35.nginx_phpfpm.php @@ -40,7 +40,7 @@ class nginx_phpfpm extends nginx $php_options_text = "\t".'location ~ \.php$ {'."\n"; $php_options_text.= "\t\t".'fastcgi_index index.php;'."\n"; $php_options_text.= "\t\t".'include /etc/nginx/fastcgi_params;'."\n"; - $php_options_text.= "\t\t".'fastcgi_param SCRIPT_FILENAME '.makeCorrectDir($domain['documentroot']).'$fastcgi_script_name;'."\n"; + $php_options_text.= "\t\t".'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;'."\n"; $php_options_text.= "\t\t".'fastcgi_pass unix:' . $php->getInterface()->getSocketFile() . ';' . "\n"; $php_options_text.= "\t".'}'."\n"; @@ -58,4 +58,47 @@ class nginx_phpfpm extends nginx return $php_options_text; } + + public function createOwnVhostStarter() + { + if ($this->settings['phpfpm']['enabled'] == '1' + && $this->settings['phpfpm']['enabled_ownvhost'] == '1' + ) { + $mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__)))); // /var/www/froxlor, needed for chown + + $user = $this->settings['phpfpm']['vhost_httpuser']; + $group = $this->settings['phpfpm']['vhost_httpgroup']; + + $domain = array( + 'id' => 'none', + 'domain' => $this->settings['system']['hostname'], + 'adminid' => 1, /* first admin-user (superadmin) */ + 'mod_fcgid_starter' => -1, + 'mod_fcgid_maxrequests' => -1, + 'guid' => $user, + 'openbasedir' => 0, + 'safemode' => '0', + 'email' => $this->settings['panel']['adminmail'], + 'loginname' => 'froxlor.panel', + 'documentroot' => $mypath + ); + + // all the files and folders have to belong to the local user + // now because we also use fcgid for our own vhost + safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath)); + + // get php.ini for our own vhost + $php = new phpinterface($this->getDB(), $this->settings, $domain); + + // @FIXME don't use fcgid settings, but we don't have anything else atm + $phpconfig = $php->getPhpConfig($this->settings['system']['mod_fcgid_defaultini_ownvhost']); + + // create starter-file | config-file + $php->getInterface()->createConfig($phpconfig); + + // create php.ini + // @TODO make php-fpm support this + $php->getInterface()->createIniFile($phpconfig); + } + } }