fixes to multi-fpm in cron
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -160,6 +160,9 @@ class phpinterface_fpm
|
|||||||
*/
|
*/
|
||||||
public function __construct($domain)
|
public function __construct($domain)
|
||||||
{
|
{
|
||||||
|
if (!isset($domain['fpm_config_id']) || empty($domain['fpm_config_id'])) {
|
||||||
|
$domain['fpm_config_id'] = 1;
|
||||||
|
}
|
||||||
$this->_domain = $domain;
|
$this->_domain = $domain;
|
||||||
$this->_readFpmConfig($domain['fpm_config_id']);
|
$this->_readFpmConfig($domain['fpm_config_id']);
|
||||||
}
|
}
|
||||||
@@ -354,7 +357,7 @@ class phpinterface_fpm
|
|||||||
*/
|
*/
|
||||||
public function getConfigFile($createifnotexists = true)
|
public function getConfigFile($createifnotexists = true)
|
||||||
{
|
{
|
||||||
$configdir = $this->_fpm_cfg['config_path'];
|
$configdir = $this->_fpm_cfg['config_dir'];
|
||||||
$config = makeCorrectFile($configdir . '/' . $this->_domain['domain'] . '.conf');
|
$config = makeCorrectFile($configdir . '/' . $this->_domain['domain'] . '.conf');
|
||||||
|
|
||||||
if (! is_dir($configdir) && $createifnotexists) {
|
if (! is_dir($configdir) && $createifnotexists) {
|
||||||
|
|||||||
@@ -46,6 +46,22 @@ class WebserverBase
|
|||||||
|
|
||||||
$result_domains_stmt = Database::query($query);
|
$result_domains_stmt = Database::query($query);
|
||||||
|
|
||||||
|
// prepare IP statement
|
||||||
|
$ip_stmt = Database::prepare("
|
||||||
|
SELECT `di`.`id_domain` , `p`.`ssl`, `p`.`ssl_cert_file`, `p`.`ssl_key_file`, `p`.`ssl_ca_file`, `p`.`ssl_cert_chainfile`
|
||||||
|
FROM `" . TABLE_DOMAINTOIP . "` `di`, `" . TABLE_PANEL_IPSANDPORTS . "` `p`
|
||||||
|
WHERE `p`.`id` = `di`.`id_ipandports`
|
||||||
|
AND `di`.`id_domain` = :domainid
|
||||||
|
AND `p`.`ssl` = '1'
|
||||||
|
");
|
||||||
|
|
||||||
|
// prepare fpm-config select query
|
||||||
|
$fpm_sel_stmt = Database::prepare("
|
||||||
|
SELECT f.id FROM `" . TABLE_PANEL_FPMDAEMONS . "` f
|
||||||
|
LEFT JOIN `" . TABLE_PANEL_PHPCONFIGS . "` p ON p.fpmsettingid = f.id
|
||||||
|
WHERE p.id = :phpconfigid
|
||||||
|
");
|
||||||
|
|
||||||
$domains = array();
|
$domains = array();
|
||||||
while ($domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
@@ -61,14 +77,7 @@ class WebserverBase
|
|||||||
// now, if the domain has an ssl ip/port assigned, get
|
// now, if the domain has an ssl ip/port assigned, get
|
||||||
// the corresponding information from the db
|
// the corresponding information from the db
|
||||||
if (domainHasSslIpPort($domain['id'])) {
|
if (domainHasSslIpPort($domain['id'])) {
|
||||||
|
|
||||||
$ip_stmt = Database::prepare("
|
|
||||||
SELECT `di`.`id_domain` , `p`.`ssl`, `p`.`ssl_cert_file`, `p`.`ssl_key_file`, `p`.`ssl_ca_file`, `p`.`ssl_cert_chainfile`
|
|
||||||
FROM `" . TABLE_DOMAINTOIP . "` `di`, `" . TABLE_PANEL_IPSANDPORTS . "` `p`
|
|
||||||
WHERE `p`.`id` = `di`.`id_ipandports`
|
|
||||||
AND `di`.`id_domain` = :domainid
|
|
||||||
AND `p`.`ssl` = '1'
|
|
||||||
");
|
|
||||||
$ssl_ip = Database::pexecute_first($ip_stmt, array(
|
$ssl_ip = Database::pexecute_first($ip_stmt, array(
|
||||||
'domainid' => $domain['id']
|
'domainid' => $domain['id']
|
||||||
));
|
));
|
||||||
@@ -83,16 +92,15 @@ class WebserverBase
|
|||||||
|
|
||||||
// read fpm-config-id if using fpm
|
// read fpm-config-id if using fpm
|
||||||
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
||||||
$fpm_sel_stmt = Database::prepare("
|
|
||||||
SELECT f.id FROM `" . TABLE_PANEL_FPMDAEMONS . "` f
|
|
||||||
LEFT JOIN `" . TABLE_PANEL_PHPCONFIGS . "` p ON p.fpmsettingid = f.id
|
|
||||||
WHERE p.id = :phpconfigid
|
|
||||||
");
|
|
||||||
$fpm_config = Database::pexecute_first($fpm_sel_stmt, array(
|
$fpm_config = Database::pexecute_first($fpm_sel_stmt, array(
|
||||||
'phpconfigid' => $domain['phpsettingid']
|
'phpconfigid' => $domain['phpsettingid']
|
||||||
));
|
));
|
||||||
if ($fpm_config) {
|
if ($fpm_config) {
|
||||||
$domains[$domain['domain']]['fpm_config_id'] = $fpm_config['id'];
|
$domains[$domain['domain']]['fpm_config_id'] = $fpm_config['id'];
|
||||||
|
} else {
|
||||||
|
// fallback
|
||||||
|
$domains[$domain['domain']]['fpm_config_id'] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,6 +287,15 @@ class apache extends HttpConfigBase
|
|||||||
$this->virtualhosts_data[$vhosts_filename] .= ' </Directory>' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' </Directory>' . "\n";
|
||||||
}
|
}
|
||||||
} elseif (Settings::Get('phpfpm.enabled') == '1') {
|
} elseif (Settings::Get('phpfpm.enabled') == '1') {
|
||||||
|
// get fpm config
|
||||||
|
$fpm_sel_stmt = Database::prepare("
|
||||||
|
SELECT f.id FROM `" . TABLE_PANEL_FPMDAEMONS . "` f
|
||||||
|
LEFT JOIN `" . TABLE_PANEL_PHPCONFIGS . "` p ON p.fpmsettingid = f.id
|
||||||
|
WHERE p.id = :phpconfigid
|
||||||
|
");
|
||||||
|
$fpm_config = Database::pexecute_first($fpm_sel_stmt, array(
|
||||||
|
'phpconfigid' => Settings::Get('phpfpm.vhost_defaultini')
|
||||||
|
));
|
||||||
// create php-fpm <Directory>-Part (config is created in apache_fcgid)
|
// create php-fpm <Directory>-Part (config is created in apache_fcgid)
|
||||||
$domain = array(
|
$domain = array(
|
||||||
'id' => 'none',
|
'id' => 'none',
|
||||||
@@ -298,7 +307,8 @@ class apache extends HttpConfigBase
|
|||||||
'openbasedir' => 0,
|
'openbasedir' => 0,
|
||||||
'email' => Settings::Get('panel.adminmail'),
|
'email' => Settings::Get('panel.adminmail'),
|
||||||
'loginname' => 'froxlor.panel',
|
'loginname' => 'froxlor.panel',
|
||||||
'documentroot' => $mypath
|
'documentroot' => $mypath,
|
||||||
|
'fpm_config_id' => isset($fpm_config['id']) ? $fpm_config['id'] : 1
|
||||||
);
|
);
|
||||||
|
|
||||||
$php = new phpinterface($domain);
|
$php = new phpinterface($domain);
|
||||||
|
|||||||
@@ -155,6 +155,16 @@ class apache_fcgid extends apache
|
|||||||
) {
|
) {
|
||||||
$user = Settings::Get('phpfpm.vhost_httpuser');
|
$user = Settings::Get('phpfpm.vhost_httpuser');
|
||||||
$group = Settings::Get('phpfpm.vhost_httpgroup');
|
$group = Settings::Get('phpfpm.vhost_httpgroup');
|
||||||
|
|
||||||
|
// get fpm config
|
||||||
|
$fpm_sel_stmt = Database::prepare("
|
||||||
|
SELECT f.id FROM `" . TABLE_PANEL_FPMDAEMONS . "` f
|
||||||
|
LEFT JOIN `" . TABLE_PANEL_PHPCONFIGS . "` p ON p.fpmsettingid = f.id
|
||||||
|
WHERE p.id = :phpconfigid
|
||||||
|
");
|
||||||
|
$fpm_config = Database::pexecute_first($fpm_sel_stmt, array(
|
||||||
|
'phpconfigid' => Settings::Get('phpfpm.vhost_defaultini')
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = array(
|
$domain = array(
|
||||||
@@ -167,7 +177,8 @@ class apache_fcgid extends apache
|
|||||||
'openbasedir' => 0,
|
'openbasedir' => 0,
|
||||||
'email' => Settings::Get('panel.adminmail'),
|
'email' => Settings::Get('panel.adminmail'),
|
||||||
'loginname' => 'froxlor.panel',
|
'loginname' => 'froxlor.panel',
|
||||||
'documentroot' => $mypath
|
'documentroot' => $mypath,
|
||||||
|
'fpm_config_id' => isset($fpm_config['id']) ? $fpm_config['id'] : 1
|
||||||
);
|
);
|
||||||
|
|
||||||
// all the files and folders have to belong to the local user
|
// all the files and folders have to belong to the local user
|
||||||
|
|||||||
Reference in New Issue
Block a user