Commit 3aaf9563 authored by Jozef Sroka's avatar Jozef Sroka
Browse files

Server php adding custom fpm_socket_dir

parent 333d13a9
-- drop old php column because new installations don't have them (fails in multi-server)
ALTER TABLE `web_domain` DROP COLUMN `fastcgi_php_version`;
-- add php_fpm_pool_dir column to server_php
ALTER TABLE `server_php` ADD `php_fpm_socket_dir` varchar(255) DEFAULT NULL AFTER `php_fpm_pool_dir`;
......@@ -1426,6 +1426,7 @@ CREATE TABLE `server_php` (
`php_fpm_init_script` varchar(255) DEFAULT NULL,
`php_fpm_ini_dir` varchar(255) DEFAULT NULL,
`php_fpm_pool_dir` varchar(255) DEFAULT NULL,
`php_fpm_socket_dir` varchar(255) DEFAULT NULL,
`active` enum('n','y') NOT NULL DEFAULT 'y',
PRIMARY KEY (`server_php_id`)
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......
......@@ -229,6 +229,20 @@ $form["tabs"]['php_fpm'] = array(
'width' => '40',
'maxlength' => '255'
),
'php_fpm_socket_dir' => array(
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'filters' => array(
0 => array( 'event' => 'SAVE',
'type' => 'STRIPTAGS'),
1 => array( 'event' => 'SAVE',
'type' => 'STRIPNL')
),
'default' => '',
'value' => '',
'width' => '40',
'maxlength' => '255'
),
//#################################
// END Datatable fields
//#################################
......
......@@ -7,6 +7,9 @@
<div class="form-group">
<label for="php_fpm_pool_dir" class="col-sm-3 control-label">{tmpl_var name='php_fpm_pool_dir_txt'}</label>
<div class="col-sm-9"><input type="text" name="php_fpm_pool_dir" id="php_fpm_pool_dir" value="{tmpl_var name='php_fpm_pool_dir'}" class="form-control" /></div></div>
<div class="form-group">
<label for="php_fpm_socket_dir" class="col-sm-3 control-label">{tmpl_var name='php_fpm_socket_dir'}</label>
<div class="col-sm-9"><input type="text" name="php_fpm_socket_dir" id="php_fpm_socket_dir" value="{tmpl_var name='php_fpm_socket_dir'}" class="form-control" /></div></div>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
......
......@@ -1667,31 +1667,30 @@ class apache2_plugin {
* PHP-FPM
*/
// Support for multiple PHP versions
$default_php_fpm = true;
if($data['new']['php'] == 'php-fpm'){
if($data['new']['server_php_id'] != 0){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
} else {
if($data['old']['server_php_id'] != 0 && ($data['old']['php'] == 'php-fpm' || $data['old']['php'] == 'hhvm')){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
}
......@@ -1704,7 +1703,12 @@ class apache2_plugin {
if(substr($pool_dir, -1) != '/') $pool_dir .= '/';
$pool_name = 'web'.$data['new']['domain_id'];
$socket_dir = $web_config['php_fpm_socket_dir'];
if (!$default_php_fpm && !empty($custom_php_fpm_socket_dir)) {
$socket_dir = $custom_php_fpm_socket_dir;
} else {
$socket_dir = $web_config['php_fpm_socket_dir'];
}
if(substr($socket_dir, -1) != '/') $socket_dir .= '/';
if($data['new']['php_fpm_use_socket'] == 'y'){
......@@ -3303,31 +3307,29 @@ class apache2_plugin {
$pool_dir = trim($pool_dir);
//$reload = false;
$default_php_fpm = true;
if($data['new']['php'] == 'php-fpm'){
if($data['new']['server_php_id'] != 0){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
} else {
if($data['old']['server_php_id'] != 0 && $data['old']['php'] == 'php-fpm'){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
}
......@@ -3525,17 +3527,17 @@ class apache2_plugin {
$php_fpm_reload_mode = ($web_config['php_fpm_reload_mode'] == 'reload')?'reload':'restart';
$default_php_fpm = true;
if($data['old']['server_php_id'] != 0 && $data['old']['php'] == 'php-fpm'){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
if($default_php_fpm){
......
......@@ -1084,31 +1084,31 @@ class nginx_plugin {
}
if($data['new']['ip_address'] == '*' && $data['new']['ipv6_address'] == '') $tpl->setVar('ipv6_wildcard', 1);
$default_php_fpm = true;
if($data['new']['php'] == 'php-fpm' || $data['new']['php'] == 'hhvm'){
if($data['new']['server_php_id'] != 0){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
} else {
if($data['old']['server_php_id'] != 0 && $data['old']['php'] != 'no'){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
}
......@@ -1120,7 +1120,12 @@ class nginx_plugin {
$pool_dir = trim($pool_dir);
if(substr($pool_dir, -1) != '/') $pool_dir .= '/';
$pool_name = 'web'.$data['new']['domain_id'];
$socket_dir = $web_config['php_fpm_socket_dir'];
if (!$default_php_fpm && !empty($custom_php_fpm_socket_dir)) {
$socket_dir = $custom_php_fpm_socket_dir;
} else {
$socket_dir = $web_config['php_fpm_socket_dir'];
}
if(substr($socket_dir, -1) != '/') $socket_dir .= '/';
if($data['new']['php_fpm_use_socket'] == 'y'){
......@@ -2876,31 +2881,29 @@ class nginx_plugin {
$rh_releasefiles = array('/etc/centos-release', '/etc/redhat-release');
// HHVM => PHP-FPM-Fallback
$default_php_fpm = true;
if($data['new']['php'] == 'php-fpm' || $data['new']['php'] == 'hhvm'){
if($data['new']['server_php_id'] != 0){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
} else {
if($data['old']['server_php_id'] != 0 && $data['old']['php'] != 'no'){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
}
......@@ -3102,17 +3105,17 @@ class nginx_plugin {
private function php_fpm_pool_delete ($data, $web_config) {
global $app, $conf;
$default_php_fpm = true;
if($data['old']['server_php_id'] != 0 && $data['old']['php'] != 'no'){
$default_php_fpm = false;
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
if($tmp_php) {
$default_php_fpm = false;
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
}
} else {
$default_php_fpm = true;
}
if($default_php_fpm){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment