Skip to content

Commit 73e6c72

Browse files
author
Marius Burkard
committed
- fixed vhost file gets written too early
1 parent 8dfe490 commit 73e6c72

File tree

1 file changed

+58
-59
lines changed

1 file changed

+58
-59
lines changed

server/lib/classes/plugin_webserver_base.inc.php

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,64 @@ public function eventUpdate($event_name, $data, $action, $server_type = 'apache'
13521352
$config_prefix = 'nginx_';
13531353
}
13541354

1355+
/**
1356+
* PHP-FPM
1357+
*/
1358+
// Support for multiple PHP versions
1359+
if($data['new']['php'] == 'php-fpm'){
1360+
if(trim($data['new']['fastcgi_php_version']) != ''){
1361+
$default_php_fpm = false;
1362+
list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
1363+
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
1364+
} else {
1365+
$default_php_fpm = true;
1366+
}
1367+
} else {
1368+
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
1369+
$default_php_fpm = false;
1370+
list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['old']['fastcgi_php_version']));
1371+
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
1372+
} else {
1373+
$default_php_fpm = true;
1374+
}
1375+
}
1376+
1377+
if($default_php_fpm){
1378+
$pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']);
1379+
} else {
1380+
$pool_dir = $custom_php_fpm_pool_dir;
1381+
}
1382+
$pool_dir = trim($pool_dir);
1383+
if(substr($pool_dir, -1) != '/') $pool_dir .= '/';
1384+
$pool_name = 'web'.$data['new']['domain_id'];
1385+
$socket_dir = escapeshellcmd($web_config['php_fpm_socket_dir']);
1386+
if(substr($socket_dir, -1) != '/') $socket_dir .= '/';
1387+
1388+
if($data['new']['php_fpm_use_socket'] == 'y'){
1389+
$use_tcp = 0;
1390+
$use_socket = 1;
1391+
if(!is_dir($socket_dir)) $app->system->mkdirpath($socket_dir);
1392+
} else {
1393+
$use_tcp = 1;
1394+
$use_socket = 0;
1395+
}
1396+
$tpl->setVar('use_tcp', $use_tcp);
1397+
$tpl->setVar('use_socket', $use_socket);
1398+
$fpm_socket = $socket_dir.$pool_name.'.sock';
1399+
$tpl->setVar('fpm_socket', $fpm_socket);
1400+
$tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1);
1401+
1402+
$this->php_fpm_pool_update($data, $web_config, $pool_dir, $pool_name, $socket_dir, $server_type);
1403+
if($server_type === 'nginx') {
1404+
$fpm_data = array(
1405+
'use_tcp' => $use_tcp,
1406+
'use_socket' => $use_socket,
1407+
'socket_dir' => $socket_dir,
1408+
'fpm_socket' => $fpm_socket,
1409+
'fpm_port' => $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1
1410+
);
1411+
$app->plugin_webserver_nginx->processCustomDirectives($tpl, $data, $vhost_data, $fpm_data);
1412+
}
13551413

13561414
$vhost_file = escapeshellcmd($web_config[$config_prefix.'vhost_conf_dir'].'/'.$data['new']['domain'].'.vhost');
13571415
//* Make a backup copy of vhost file
@@ -1461,65 +1519,6 @@ public function eventUpdate($event_name, $data, $action, $server_type = 'apache'
14611519
$app->plugin_webserver_base->awstats_update($data, $web_config);
14621520
}
14631521

1464-
/**
1465-
* PHP-FPM
1466-
*/
1467-
// Support for multiple PHP versions
1468-
if($data['new']['php'] == 'php-fpm'){
1469-
if(trim($data['new']['fastcgi_php_version']) != ''){
1470-
$default_php_fpm = false;
1471-
list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['new']['fastcgi_php_version']));
1472-
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
1473-
} else {
1474-
$default_php_fpm = true;
1475-
}
1476-
} else {
1477-
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
1478-
$default_php_fpm = false;
1479-
list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($data['old']['fastcgi_php_version']));
1480-
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
1481-
} else {
1482-
$default_php_fpm = true;
1483-
}
1484-
}
1485-
1486-
if($default_php_fpm){
1487-
$pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']);
1488-
} else {
1489-
$pool_dir = $custom_php_fpm_pool_dir;
1490-
}
1491-
$pool_dir = trim($pool_dir);
1492-
if(substr($pool_dir, -1) != '/') $pool_dir .= '/';
1493-
$pool_name = 'web'.$data['new']['domain_id'];
1494-
$socket_dir = escapeshellcmd($web_config['php_fpm_socket_dir']);
1495-
if(substr($socket_dir, -1) != '/') $socket_dir .= '/';
1496-
1497-
if($data['new']['php_fpm_use_socket'] == 'y'){
1498-
$use_tcp = 0;
1499-
$use_socket = 1;
1500-
if(!is_dir($socket_dir)) $app->system->mkdirpath($socket_dir);
1501-
} else {
1502-
$use_tcp = 1;
1503-
$use_socket = 0;
1504-
}
1505-
$tpl->setVar('use_tcp', $use_tcp);
1506-
$tpl->setVar('use_socket', $use_socket);
1507-
$fpm_socket = $socket_dir.$pool_name.'.sock';
1508-
$tpl->setVar('fpm_socket', $fpm_socket);
1509-
$tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1);
1510-
1511-
$this->php_fpm_pool_update($data, $web_config, $pool_dir, $pool_name, $socket_dir, $server_type);
1512-
if($server_type === 'nginx') {
1513-
$fpm_data = array(
1514-
'use_tcp' => $use_tcp,
1515-
'use_socket' => $use_socket,
1516-
'socket_dir' => $socket_dir,
1517-
'fpm_socket' => $fpm_socket,
1518-
'fpm_port' => $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1
1519-
);
1520-
$app->plugin_webserver_nginx->processCustomDirectives($tpl, $data, $vhost_data, $fpm_data);
1521-
}
1522-
15231522
if($web_config['check_apache_config'] == 'y') {
15241523
//* Test if server starts with the new configuration file
15251524
$online_status_before_restart = $this->_checkTcp('localhost', 80);

0 commit comments

Comments
 (0)