From 9b155852f4a352ddb793ac4252702170b6509c17 Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Sun, 11 May 2014 17:39:51 -0400
Subject: [PATCH] Merge branch 'master' of git.ispconfig.org:ispconfig/ispconfig3
---
server/plugins-available/apache2_plugin.inc.php | 61 ++++++++++++++++++++++++++----
1 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 18c4ded..f1a08af 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -104,7 +104,7 @@
/* $data contains an array with these keys:
* file -> full path of changed php_ini
- * mode -> web_domain php modes to change (mod, fast-cgi, php-fpm or '' for all except 'mod')
+ * mode -> web_domain php modes to change (mod, fast-cgi, php-fpm, hhvm or '' for all except 'mod')
* php_version -> php ini path that changed (additional php versions)
*/
@@ -118,6 +118,11 @@
}
} elseif($data['mode'] == 'php-fpm') {
$qrystr .= " AND php = 'php-fpm'";
+ if($data['php_version']) {
+ $qrystr .= " AND fastcgi_php_version LIKE '%:" . $app->db->quote($data['php_version']) . ":%'";
+ }
+ } elseif($data['mode'] == 'hhvm') {
+ $qrystr .= " AND php = 'hhvm'";
if($data['php_version']) {
$qrystr .= " AND fastcgi_php_version LIKE '%:" . $app->db->quote($data['php_version']) . ":%'";
}
@@ -444,13 +449,26 @@
$web_folder = 'web';
$log_folder = 'log';
+ $old_web_folder = 'web';
+ $old_log_folder = 'log';
if($data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias') {
+ // new one
$tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['new']['parent_domain_id']));
$subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['new']['domain']);
if($subdomain_host == '') $subdomain_host = 'web'.$data['new']['domain_id'];
$web_folder = $data['new']['web_folder'];
$log_folder .= '/' . $subdomain_host;
unset($tmp);
+
+ if(isset($data['old']['parent_domain_id'])) {
+ // old one
+ $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['old']['parent_domain_id']));
+ $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['old']['domain']);
+ if($subdomain_host == '') $subdomain_host = 'web'.$data['old']['domain_id'];
+ $old_web_folder = $data['old']['web_folder'];
+ $old_log_folder .= '/' . $subdomain_host;
+ unset($tmp);
+ }
}
// Create group and user, if not exist
@@ -562,9 +580,9 @@
if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command);
//* Change the log mount
- $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$log_folder.' none bind';
+ $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$old_log_folder.' none bind';
$app->system->removeLine('/etc/fstab', $fstab_line);
- $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$log_folder.' none bind,nobootwait';
+ $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$old_log_folder.' none bind,nobootwait';
$app->system->removeLine('/etc/fstab', $fstab_line);
$fstab_line = '/var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/'.$log_folder.' none bind,nobootwait,_netdev 0 0';
$app->system->replaceLine('/etc/fstab', $fstab_line, $fstab_line, 1, 1);
@@ -596,14 +614,14 @@
// Remove the symlink for the site, if site is renamed
if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
if(is_dir('/var/log/ispconfig/httpd/'.$data['old']['domain'])) exec('rm -rf /var/log/ispconfig/httpd/'.$data['old']['domain']);
- if(is_link($data['old']['document_root'].'/'.$log_folder)) $app->system->unlink($data['old']['document_root'].'/'.$log_folder);
+ if(is_link($data['old']['document_root'].'/'.$old_log_folder)) $app->system->unlink($data['old']['document_root'].'/'.$old_log_folder);
//* remove old log mount
- $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$log_folder.' none bind';
+ $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$old_log_folder.' none bind';
$app->system->removeLine('/etc/fstab', $fstab_line);
//* Unmount log directory
- exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$log_folder));
+ exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$old_log_folder));
}
//* Create the log dir if nescessary and mount it
@@ -1305,7 +1323,7 @@
* PHP-FPM
*/
// Support for multiple PHP versions
- if($data['new']['php'] == 'php-fpm'){
+ if($data['new']['php'] == 'php-fpm' || $data['new']['php'] == 'hhvm'){
if(trim($data['new']['fastcgi_php_version']) != ''){
$default_php_fpm = false;
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']));
@@ -1314,7 +1332,7 @@
$default_php_fpm = true;
}
} else {
- if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
+ if(trim($data['old']['fastcgi_php_version']) != '' && ($data['old']['php'] == 'php-fpm' || $data['old']['php'] == 'hhvm')){
$default_php_fpm = false;
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']));
if(substr($custom_php_fpm_ini_dir, -1) != '/') $custom_php_fpm_ini_dir .= '/';
@@ -1573,6 +1591,7 @@
}
$this->php_fpm_pool_update($data, $web_config, $pool_dir, $pool_name, $socket_dir);
+ $this->hhvm_update($data, $web_config);
if($web_config['check_apache_config'] == 'y') {
//* Test if apache starts with the new configuration file
@@ -1713,7 +1732,6 @@
//* Unset action to clean it for next processed vhost.
$this->action = '';
-
}
function delete($event_name, $data) {
@@ -1921,6 +1939,8 @@
// remove PHP-FPM pool
if ($data['old']['php'] == 'php-fpm') {
$this->php_fpm_pool_delete($data, $web_config);
+ } elseif($data['old']['php'] == 'hhvm') {
+ $this->hhvm_update($data, $web_config);
}
//remove the php cgi starter script if available
@@ -2710,6 +2730,28 @@
}
}
+ private function hhvm_update($data, $web_config) {
+ global $app, $conf;
+
+ if(file_exists($conf['rootpath'] . '/conf-custom/hhvm_starter.master')) {
+ $content = file_get_contents($conf['rootpath'] . '/conf-custom/hhvm_starter.master');
+ } else {
+ $content = file_get_contents($conf['rootpath'] . '/conf/hhvm_starter.master');
+ }
+
+ if($data['new']['php'] == 'hhvm' && $data['old']['php'] != 'hhvm') {
+ $content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $content);
+ file_put_contents('/etc/init.d/hhvm_' . $data['new']['system_user'], $content);
+ exec('chmod +x /etc/init.d/hhvm_' . $data['new']['system_user'] . ' >/dev/null 2>&1');
+ exec('/usr/sbin/update-rc.d hhvm_' . $data['new']['system_user'] . ' defaults >/dev/null 2>&1');
+ exec('/etc/init.d/hhvm_' . $data['new']['system_user'] . ' start >/dev/null 2>&1');
+ } elseif($data['new']['php'] != 'hhvm' && $data['old']['php'] == 'hhvm') {
+ exec('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' stop >/dev/null 2>&1');
+ exec('/usr/sbin/update-rc.d hhvm_' . $data['old']['system_user'] . ' remove >/dev/null 2>&1');
+ unlink('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' >/dev/null 2>&1');
+ }
+ }
+
//* Update the PHP-FPM pool configuration file
private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name, $socket_dir) {
global $app, $conf;
@@ -2770,6 +2812,7 @@
$fpm_socket = $socket_dir.$pool_name.'.sock';
$tpl->setVar('fpm_socket', $fpm_socket);
+ $tpl->setVar('fpm_listen_mode', '0600');
$tpl->setVar('fpm_pool', $pool_name);
$tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1);
--
Gitblit v1.9.1