Commit c9b9f2fb authored by tbrehm's avatar tbrehm

Added: FS#871 - Add a "apps" vhost for applications like phpmyadmin and webmail

parent e37a3aa8
......@@ -87,6 +87,13 @@ $conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
......
......@@ -87,6 +87,13 @@ $conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
......
......@@ -87,6 +87,13 @@ $conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
......
......@@ -87,6 +87,13 @@ $conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
......
......@@ -87,6 +87,13 @@ $conf['web']['website_basedir'] = '/srv/www';
$conf['web']['website_path'] = '/srv/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/srv/www/[website_domain]/:/srv/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/srv/www/php-fcgi-scripts/[system_user]/';
......
......@@ -206,6 +206,10 @@ if($install_mode == 'standard') {
//** Configure vlogger
swriteln('Configuring vlogger');
$inst->configure_vlogger();
//** Configure apps vhost
swriteln('Configuring Apps vhost');
$inst->configure_apps_vhost();
//* Configure Firewall
swriteln('Configuring Firewall');
......@@ -384,6 +388,10 @@ if($install_mode == 'standard') {
//** Configure vlogger
swriteln('Configuring vlogger');
$inst->configure_vlogger();
//** Configure apps vhost
swriteln('Configuring Apps vhost');
$inst->configure_apps_vhost();
}
//** Configure Firewall
......
......@@ -970,6 +970,67 @@ class installer_base {
exec('chown root:root '.$conf["vlogger"]["config_dir"].'/'.$configfile);
}
public function install_apps_vhost()
{
global $conf;
//* Create the ispconfig apps vhost user and group
$apps_vhost_user = $conf['web']['apps_vhost_user'];
$apps_vhost_group = $conf['web']['apps_vhost_group'];
$command = 'groupadd '.$apps_vhost_user;
if(!is_group($apps_vhost_group)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
$command = "useradd -g '$apps_vhost_group' -d $install_dir $apps_vhost_group";
if(!is_user($apps_vhost_user)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
$command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
//* Copy the apps vhost file
$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
$apps_vhost_servername = ($conf['apache']['apps_vhost_servername'] == '')?'':'ServerName '.$conf['apache']['apps_vhost_servername'];
// Dont just copy over the virtualhost template but add some custom settings
$content = rf("tpl/apache_apps.vhost.master");
$content = str_replace('{apps_vhost_ip}', $conf['apache']['apps_vhost_ip'], $content);
$content = str_replace('{apps_vhost_port}', $conf['apache']['apps_vhost_port'], $content);
$content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
// comment out the listen directive if port is 80 or 443
if($conf['apache']['apps_vhost_ip'] == 80 or $conf['apache']['apps_vhost_ip'] == 443) {
$content = str_replace('{vhost_port_listen}', '#', $content);
} else {
$content = str_replace('{vhost_port_listen}', '', $content);
}
wf("$vhost_conf_dir/apps.vhost", $content);
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
//* and create the symlink
if($this->install_ispconfig_interface == true && $this->is_update == false) {
if(@is_link("$vhost_conf_enabled_dir/apps.vhost")) unlink("$vhost_conf_enabled_dir/apps.vhost");
if(!@is_link("$vhost_conf_enabled_dir/000-apps.vhost")) {
exec("ln -s $vhost_conf_dir/apps.vhost $vhost_conf_enabled_dir/000-apps.vhost");
}
}
if(!is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter')) {
exec('mkdir -p '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
exec('cp tpl/apache_apps_fcgi_starter.master '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
exec('ln -s /usr/local/apps/interface/web '.$conf['web']['website_basedir'].'/apps');
exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
}
}
public function install_ispconfig()
{
......
######################################################
# This virtual host contains the configuration
# for the ISPConfig apps vhost
######################################################
{vhost_port_listen} Listen {apps_vhost_port}
NameVirtualHost *:{apps_vhost_port}
<VirtualHost {apps_vhost_ip}:{apps_vhost_port}>
ServerAdmin webmaster@localhost
{apps_vhost_servername}
<IfModule mod_fcgid.c>
DocumentRoot {apps_vhost_dir}
SuexecUserGroup ispapps ispapps
<Directory {apps_vhost_dir}>
Options Indexes FollowSymLinks MultiViews +ExecCGI
AllowOverride AuthConfig Indexes Limit Options FileInfo
AddHandler fcgid-script .php
FCGIWrapper /var/www/php-fcgi-scripts/apps/.php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
</IfModule>
<IfModule mod_php5.c>
DocumentRoot {apps_vhost_dir}
AddType application/x-httpd-php .php
<Directory {apps_vhost_dir}>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>
ServerSignature Off
</VirtualHost>
#!/bin/sh
PHPRC=/etc/php5/cgi/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=1
exec /usr/lib/cgi-bin/php -d magic_quotes_gpc=off
\ No newline at end of file
......@@ -2,5 +2,5 @@
PHPRC=/etc/php5/cgi/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
export PHP_FCGI_CHILDREN=1
exec /usr/lib/cgi-bin/php -d magic_quotes_gpc=off
\ No newline at end of file
......@@ -39,6 +39,9 @@ vhost_conf_enabled_dir=/etc/apache2/sites-enabled
security_level=10
user=www-data
group=www-data
apps_vhost_port=8081
apps_vhost_ip=_default_
apps_vhost_servername=
[fastcgi]
fastcgi_starter_path=/var/www/php-fcgi-scripts/[system_user]/
......
......@@ -356,6 +356,10 @@ if($reconfigure_services_answer == 'yes') {
//** Configure vlogger
swriteln('Configuring vlogger');
$inst->configure_vlogger();
//** Configure apps vhost
swriteln('Configuring Apps vhost');
$inst->configure_apps_vhost();
}
......
......@@ -375,6 +375,39 @@ $form["tabs"]['web'] = array (
'width' => '40',
'maxlength' => '255'
),
'apps_vhost_port' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '8081',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'apps_vhost_port_error_empty'),
),
'value' => '',
'width' => '40',
'maxlength' => '255'
),
'apps_vhost_ip' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '_default_',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'apps_vhost_ip_error_empty'),
),
'value' => '',
'width' => '40',
'maxlength' => '255'
),
'apps_vhost_servername' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'apps_vhost_servername_error_empty'),
),
'value' => '',
'width' => '40',
'maxlength' => '255'
),
##################################
# ENDE Datatable fields
##################################
......
......@@ -40,7 +40,19 @@
<div class="ctrlHolder">
<label for="group">{tmpl_var name='web_group_txt'}</label>
<input name="group" id="group" value="{tmpl_var name='group'}" size="40" maxlength="255" type="text" class="textInput" />
</div>
</div>
<div class="ctrlHolder">
<label for="apps_vhost_port">{tmpl_var name='apps_vhost_port_txt'}</label>
<input name="apps_vhost_port" id="apps_vhost_port" value="{tmpl_var name='apps_vhost_port'}" size="40" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="apps_vhost_ip">{tmpl_var name='apps_vhost_ip_txt'}</label>
<input name="apps_vhost_ip" id="apps_vhost_ip" value="{tmpl_var name='apps_vhost_ip'}" size="40" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="apps_vhost_servername">{tmpl_var name='apps_vhost_servername_txt'}</label>
<input name="apps_vhost_servername" id="apps_vhost_servername" value="{tmpl_var name='apps_vhost_servername'}" size="40" maxlength="255" type="text" class="textInput" />
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
......
######################################################
# This virtual host contains the configuration
# for the ISPConfig apps vhost
######################################################
{vhost_port_listen} Listen {apps_vhost_port}
NameVirtualHost *:{apps_vhost_port}
<VirtualHost {apps_vhost_ip}:{apps_vhost_port}>
ServerAdmin webmaster@localhost
{apps_vhost_servername}
<IfModule mod_fcgid.c>
DocumentRoot {apps_vhost_dir}
SuexecUserGroup ispapps ispapps
<Directory {apps_vhost_dir}>
Options Indexes FollowSymLinks MultiViews +ExecCGI
AllowOverride AuthConfig Indexes Limit Options FileInfo
AddHandler fcgid-script .php
FCGIWrapper /var/www/php-fcgi-scripts/apps/.php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
</IfModule>
<IfModule mod_php5.c>
DocumentRoot {apps_vhost_dir}
AddType application/x-httpd-php .php
<Directory {apps_vhost_dir}>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>
ServerSignature Off
</VirtualHost>
<?php
/*
Copyright (c) 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class apps_vhost_plugin {
var $plugin_name = 'apps_vhost_plugin';
var $class_name = 'apps_vhost_plugin';
//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function onInstall() {
global $conf;
return true;
}
/*
This function is called when the plugin is loaded
*/
function onLoad() {
global $app;
/*
Register for the events
*/
$app->plugins->registerEvent('server_insert','apps_vhost_plugin','insert');
$app->plugins->registerEvent('server_update','apps_vhost_plugin','update');
}
function insert($event_name,$data) {
global $app, $conf;
$this->update($event_name,$data);
}
// The purpose of this plugin is to rewrite the main.cf file
function update($event_name,$data) {
global $app, $conf;
if( $data['old']['apps_vhost_ip'] != $data['new']['apps_vhost_ip'] or
$data['old']['apps_vhost_port'] != $data['new']['apps_vhost_port'] or
$data['old']['apps_vhost_servername'] != $data['new']['apps_vhost_servername'] ) {
// get the config
$app->uses("getconf");
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
// Dont just copy over the virtualhost template but add some custom settings
$content = rf("conf/apache_apps.vhost.master");
$vhost_conf_dir = $web_config['vhost_conf_dir'];
$vhost_conf_enabled_dir = $web_config['vhost_conf_enabled_dir'];
$apps_vhost_servername = ($web_config['apps_vhost_servername'] == '')?'':'ServerName '.$web_config['apps_vhost_servername'];
$content = str_replace('{apps_vhost_ip}', $web_config['apps_vhost_ip'], $content);
$content = str_replace('{apps_vhost_port}', $web_config['apps_vhost_port'], $content);
$content = str_replace('{apps_vhost_dir}', $web_config['website_basedir'].'/apps', $content);
$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
// comment out the listen directive if port is 80 or 443
if($web_config['apps_vhost_ip'] == 80 or $web_config['apps_vhost_ip'] == 443) {
$content = str_replace('{vhost_port_listen}', '#', $content);
} else {
$content = str_replace('{vhost_port_listen}', '', $content);
}
wf("$vhost_conf_dir/apps.vhost", $content);
}
}
} // end class
?>
\ No newline at end of file
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