Skip to content

Commit 3aaf956

Browse files
committed
Server php adding custom fpm_socket_dir
1 parent 333d13a commit 3aaf956

File tree

6 files changed

+58
-32
lines changed

6 files changed

+58
-32
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
-- drop old php column because new installations don't have them (fails in multi-server)
22
ALTER TABLE `web_domain` DROP COLUMN `fastcgi_php_version`;
3+
4+
-- add php_fpm_pool_dir column to server_php
5+
ALTER TABLE `server_php` ADD `php_fpm_socket_dir` varchar(255) DEFAULT NULL AFTER `php_fpm_pool_dir`;

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ CREATE TABLE `server_php` (
14261426
`php_fpm_init_script` varchar(255) DEFAULT NULL,
14271427
`php_fpm_ini_dir` varchar(255) DEFAULT NULL,
14281428
`php_fpm_pool_dir` varchar(255) DEFAULT NULL,
1429+
`php_fpm_socket_dir` varchar(255) DEFAULT NULL,
14291430
`active` enum('n','y') NOT NULL DEFAULT 'y',
14301431
PRIMARY KEY (`server_php_id`)
14311432
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

interface/web/admin/form/server_php.tform.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@
229229
'width' => '40',
230230
'maxlength' => '255'
231231
),
232+
'php_fpm_socket_dir' => array(
233+
'datatype' => 'VARCHAR',
234+
'formtype' => 'TEXT',
235+
'filters' => array(
236+
0 => array( 'event' => 'SAVE',
237+
'type' => 'STRIPTAGS'),
238+
1 => array( 'event' => 'SAVE',
239+
'type' => 'STRIPNL')
240+
),
241+
'default' => '',
242+
'value' => '',
243+
'width' => '40',
244+
'maxlength' => '255'
245+
),
232246
//#################################
233247
// END Datatable fields
234248
//#################################

interface/web/admin/templates/server_php_fpm_edit.htm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<div class="form-group">
88
<label for="php_fpm_pool_dir" class="col-sm-3 control-label">{tmpl_var name='php_fpm_pool_dir_txt'}</label>
99
<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>
10+
<div class="form-group">
11+
<label for="php_fpm_socket_dir" class="col-sm-3 control-label">{tmpl_var name='php_fpm_socket_dir'}</label>
12+
<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>
1013

1114

1215
<input type="hidden" name="id" value="{tmpl_var name='id'}">

server/plugins-available/apache2_plugin.inc.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,31 +1667,30 @@ function update($event_name, $data) {
16671667
* PHP-FPM
16681668
*/
16691669
// Support for multiple PHP versions
1670+
$default_php_fpm = true;
16701671
if($data['new']['php'] == 'php-fpm'){
16711672
if($data['new']['server_php_id'] != 0){
1672-
$default_php_fpm = false;
16731673
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);
16741674
if($tmp_php) {
1675+
$default_php_fpm = false;
16751676
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
16761677
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
16771678
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
1679+
$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
16781680
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
16791681
}
1680-
} else {
1681-
$default_php_fpm = true;
16821682
}
16831683
} else {
16841684
if($data['old']['server_php_id'] != 0 && ($data['old']['php'] == 'php-fpm' || $data['old']['php'] == 'hhvm')){
1685-
$default_php_fpm = false;
16861685
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
16871686
if($tmp_php) {
1687+
$default_php_fpm = false;
16881688
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
16891689
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
16901690
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
1691+
$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
16911692
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
16921693
}
1693-
} else {
1694-
$default_php_fpm = true;
16951694
}
16961695
}
16971696

@@ -1704,7 +1703,12 @@ function update($event_name, $data) {
17041703

17051704
if(substr($pool_dir, -1) != '/') $pool_dir .= '/';
17061705
$pool_name = 'web'.$data['new']['domain_id'];
1707-
$socket_dir = $web_config['php_fpm_socket_dir'];
1706+
1707+
if (!$default_php_fpm && !empty($custom_php_fpm_socket_dir)) {
1708+
$socket_dir = $custom_php_fpm_socket_dir;
1709+
} else {
1710+
$socket_dir = $web_config['php_fpm_socket_dir'];
1711+
}
17081712
if(substr($socket_dir, -1) != '/') $socket_dir .= '/';
17091713

17101714
if($data['new']['php_fpm_use_socket'] == 'y'){
@@ -3303,31 +3307,29 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
33033307
$pool_dir = trim($pool_dir);
33043308
//$reload = false;
33053309

3310+
$default_php_fpm = true;
3311+
33063312
if($data['new']['php'] == 'php-fpm'){
33073313
if($data['new']['server_php_id'] != 0){
3308-
$default_php_fpm = false;
33093314
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);
33103315
if($tmp_php) {
3316+
$default_php_fpm = false;
33113317
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
33123318
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
33133319
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
33143320
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
33153321
}
3316-
} else {
3317-
$default_php_fpm = true;
33183322
}
33193323
} else {
33203324
if($data['old']['server_php_id'] != 0 && $data['old']['php'] == 'php-fpm'){
3321-
$default_php_fpm = false;
33223325
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
33233326
if($tmp_php) {
3327+
$default_php_fpm = false;
33243328
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
33253329
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
33263330
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
33273331
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
33283332
}
3329-
} else {
3330-
$default_php_fpm = true;
33313333
}
33323334
}
33333335

@@ -3525,17 +3527,17 @@ private function php_fpm_pool_delete ($data, $web_config) {
35253527

35263528
$php_fpm_reload_mode = ($web_config['php_fpm_reload_mode'] == 'reload')?'reload':'restart';
35273529

3530+
$default_php_fpm = true;
3531+
35283532
if($data['old']['server_php_id'] != 0 && $data['old']['php'] == 'php-fpm'){
3529-
$default_php_fpm = false;
35303533
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
35313534
if($tmp_php) {
3535+
$default_php_fpm = false;
35323536
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
35333537
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
35343538
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
35353539
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
35363540
}
3537-
} else {
3538-
$default_php_fpm = true;
35393541
}
35403542

35413543
if($default_php_fpm){

server/plugins-available/nginx_plugin.inc.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,31 +1084,31 @@ function update($event_name, $data) {
10841084
}
10851085
if($data['new']['ip_address'] == '*' && $data['new']['ipv6_address'] == '') $tpl->setVar('ipv6_wildcard', 1);
10861086

1087+
$default_php_fpm = true;
1088+
10871089
if($data['new']['php'] == 'php-fpm' || $data['new']['php'] == 'hhvm'){
10881090
if($data['new']['server_php_id'] != 0){
1089-
$default_php_fpm = false;
10901091
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);
10911092
if($tmp_php) {
1093+
$default_php_fpm = false;
10921094
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
10931095
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
10941096
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
1097+
$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
10951098
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
10961099
}
1097-
} else {
1098-
$default_php_fpm = true;
10991100
}
11001101
} else {
11011102
if($data['old']['server_php_id'] != 0 && $data['old']['php'] != 'no'){
1102-
$default_php_fpm = false;
11031103
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
11041104
if($tmp_php) {
1105+
$default_php_fpm = false;
11051106
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
11061107
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
11071108
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
1109+
$custom_php_fpm_socket_dir = $tmp_php['custom_php_fpm_socket_dir'];
11081110
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
11091111
}
1110-
} else {
1111-
$default_php_fpm = true;
11121112
}
11131113
}
11141114

@@ -1120,7 +1120,12 @@ function update($event_name, $data) {
11201120
$pool_dir = trim($pool_dir);
11211121
if(substr($pool_dir, -1) != '/') $pool_dir .= '/';
11221122
$pool_name = 'web'.$data['new']['domain_id'];
1123-
$socket_dir = $web_config['php_fpm_socket_dir'];
1123+
1124+
if (!$default_php_fpm && !empty($custom_php_fpm_socket_dir)) {
1125+
$socket_dir = $custom_php_fpm_socket_dir;
1126+
} else {
1127+
$socket_dir = $web_config['php_fpm_socket_dir'];
1128+
}
11241129
if(substr($socket_dir, -1) != '/') $socket_dir .= '/';
11251130

11261131
if($data['new']['php_fpm_use_socket'] == 'y'){
@@ -2876,31 +2881,29 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
28762881
$rh_releasefiles = array('/etc/centos-release', '/etc/redhat-release');
28772882

28782883
// HHVM => PHP-FPM-Fallback
2884+
$default_php_fpm = true;
2885+
28792886
if($data['new']['php'] == 'php-fpm' || $data['new']['php'] == 'hhvm'){
28802887
if($data['new']['server_php_id'] != 0){
2881-
$default_php_fpm = false;
28822888
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['new']['server_php_id']);
28832889
if($tmp_php) {
2890+
$default_php_fpm = false;
28842891
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
28852892
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
28862893
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
28872894
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
28882895
}
2889-
} else {
2890-
$default_php_fpm = true;
28912896
}
28922897
} else {
28932898
if($data['old']['server_php_id'] != 0 && $data['old']['php'] != 'no'){
2894-
$default_php_fpm = false;
28952899
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
28962900
if($tmp_php) {
2901+
$default_php_fpm = false;
28972902
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
28982903
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
28992904
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
29002905
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
29012906
}
2902-
} else {
2903-
$default_php_fpm = true;
29042907
}
29052908
}
29062909

@@ -3102,17 +3105,17 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
31023105
private function php_fpm_pool_delete ($data, $web_config) {
31033106
global $app, $conf;
31043107

3108+
$default_php_fpm = true;
3109+
31053110
if($data['old']['server_php_id'] != 0 && $data['old']['php'] != 'no'){
3106-
$default_php_fpm = false;
31073111
$tmp_php = $app->db->queryOneRecord('SELECT * FROM server_php WHERE server_php_id = ?', $data['old']['server_php_id']);
31083112
if($tmp_php) {
3113+
$default_php_fpm = false;
31093114
$custom_php_fpm_ini_dir = $tmp_php['php_fpm_ini_dir'];
31103115
$custom_php_fpm_init_script = $tmp_php['php_fpm_init_script'];
31113116
$custom_php_fpm_pool_dir = $tmp_php['php_fpm_pool_dir'];
31123117
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
31133118
}
3114-
} else {
3115-
$default_php_fpm = true;
31163119
}
31173120

31183121
if($default_php_fpm){

0 commit comments

Comments
 (0)