Skip to content

Commit c9b9f2f

Browse files
committed
Added: FS#871 - Add a "apps" vhost for applications like phpmyadmin and webmail
1 parent e37a3aa commit c9b9f2f

16 files changed

+361
-2
lines changed

install/dist/conf/centos52.conf.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@
8787
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
8888
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
8989

90+
//* Apps base settings
91+
$conf['web']['apps_vhost_ip'] = '_default_';
92+
$conf['web']['apps_vhost_port'] = '8081';
93+
$conf['web']['apps_vhost_servername'] = '';
94+
$conf['web']['apps_vhost_user'] = 'ispapps';
95+
$conf['web']['apps_vhost_group'] = 'ispapps';
96+
9097
//* Fastcgi
9198
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/';
9299
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';

install/dist/conf/centos53.conf.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@
8787
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
8888
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
8989

90+
//* Apps base settings
91+
$conf['web']['apps_vhost_ip'] = '_default_';
92+
$conf['web']['apps_vhost_port'] = '8081';
93+
$conf['web']['apps_vhost_servername'] = '';
94+
$conf['web']['apps_vhost_user'] = 'ispapps';
95+
$conf['web']['apps_vhost_group'] = 'ispapps';
96+
9097
//* Fastcgi
9198
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/';
9299
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';

install/dist/conf/debian40.conf.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@
8787
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
8888
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
8989

90+
//* Apps base settings
91+
$conf['web']['apps_vhost_ip'] = '_default_';
92+
$conf['web']['apps_vhost_port'] = '8081';
93+
$conf['web']['apps_vhost_servername'] = '';
94+
$conf['web']['apps_vhost_user'] = 'ispapps';
95+
$conf['web']['apps_vhost_group'] = 'ispapps';
96+
9097
//* Fastcgi
9198
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
9299
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';

install/dist/conf/fedora9.conf.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@
8787
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
8888
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
8989

90+
//* Apps base settings
91+
$conf['web']['apps_vhost_ip'] = '_default_';
92+
$conf['web']['apps_vhost_port'] = '8081';
93+
$conf['web']['apps_vhost_servername'] = '';
94+
$conf['web']['apps_vhost_user'] = 'ispapps';
95+
$conf['web']['apps_vhost_group'] = 'ispapps';
96+
9097
//* Fastcgi
9198
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/';
9299
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';

install/dist/conf/opensuse110.conf.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@
8787
$conf['web']['website_path'] = '/srv/www/clients/client[client_id]/web[website_id]';
8888
$conf['web']['website_symlinks'] = '/srv/www/[website_domain]/:/srv/www/clients/client[client_id]/[website_domain]/';
8989

90+
//* Apps base settings
91+
$conf['web']['apps_vhost_ip'] = '_default_';
92+
$conf['web']['apps_vhost_port'] = '8081';
93+
$conf['web']['apps_vhost_servername'] = '';
94+
$conf['web']['apps_vhost_user'] = 'ispapps';
95+
$conf['web']['apps_vhost_group'] = 'ispapps';
96+
9097
//* Fastcgi
9198
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
9299
$conf['fastcgi']['fastcgi_starter_path'] = '/srv/www/php-fcgi-scripts/[system_user]/';

install/install.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@
206206
//** Configure vlogger
207207
swriteln('Configuring vlogger');
208208
$inst->configure_vlogger();
209+
210+
//** Configure apps vhost
211+
swriteln('Configuring Apps vhost');
212+
$inst->configure_apps_vhost();
209213

210214
//* Configure Firewall
211215
swriteln('Configuring Firewall');
@@ -384,6 +388,10 @@
384388
//** Configure vlogger
385389
swriteln('Configuring vlogger');
386390
$inst->configure_vlogger();
391+
392+
//** Configure apps vhost
393+
swriteln('Configuring Apps vhost');
394+
$inst->configure_apps_vhost();
387395
}
388396

389397
//** Configure Firewall

install/lib/installer_base.lib.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,67 @@ public function configure_vlogger()
970970
exec('chown root:root '.$conf["vlogger"]["config_dir"].'/'.$configfile);
971971

972972
}
973+
974+
public function install_apps_vhost()
975+
{
976+
global $conf;
977+
978+
//* Create the ispconfig apps vhost user and group
979+
980+
$apps_vhost_user = $conf['web']['apps_vhost_user'];
981+
$apps_vhost_group = $conf['web']['apps_vhost_group'];
982+
983+
$command = 'groupadd '.$apps_vhost_user;
984+
if(!is_group($apps_vhost_group)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
985+
986+
$command = "useradd -g '$apps_vhost_group' -d $install_dir $apps_vhost_group";
987+
if(!is_user($apps_vhost_user)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
988+
989+
990+
$command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
991+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
992+
993+
//* Copy the apps vhost file
994+
$vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
995+
$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
996+
$apps_vhost_servername = ($conf['apache']['apps_vhost_servername'] == '')?'':'ServerName '.$conf['apache']['apps_vhost_servername'];
997+
998+
// Dont just copy over the virtualhost template but add some custom settings
999+
$content = rf("tpl/apache_apps.vhost.master");
1000+
1001+
$content = str_replace('{apps_vhost_ip}', $conf['apache']['apps_vhost_ip'], $content);
1002+
$content = str_replace('{apps_vhost_port}', $conf['apache']['apps_vhost_port'], $content);
1003+
$content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
1004+
$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
1005+
1006+
1007+
// comment out the listen directive if port is 80 or 443
1008+
if($conf['apache']['apps_vhost_ip'] == 80 or $conf['apache']['apps_vhost_ip'] == 443) {
1009+
$content = str_replace('{vhost_port_listen}', '#', $content);
1010+
} else {
1011+
$content = str_replace('{vhost_port_listen}', '', $content);
1012+
}
1013+
1014+
wf("$vhost_conf_dir/apps.vhost", $content);
1015+
1016+
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
1017+
//* and create the symlink
1018+
if($this->install_ispconfig_interface == true && $this->is_update == false) {
1019+
if(@is_link("$vhost_conf_enabled_dir/apps.vhost")) unlink("$vhost_conf_enabled_dir/apps.vhost");
1020+
if(!@is_link("$vhost_conf_enabled_dir/000-apps.vhost")) {
1021+
exec("ln -s $vhost_conf_dir/apps.vhost $vhost_conf_enabled_dir/000-apps.vhost");
1022+
}
1023+
}
1024+
if(!is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter')) {
1025+
exec('mkdir -p '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
1026+
exec('cp tpl/apache_apps_fcgi_starter.master '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
1027+
exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
1028+
exec('ln -s /usr/local/apps/interface/web '.$conf['web']['website_basedir'].'/apps');
1029+
exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
1030+
1031+
}
1032+
1033+
}
9731034

9741035
public function install_ispconfig()
9751036
{
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
######################################################
3+
# This virtual host contains the configuration
4+
# for the ISPConfig apps vhost
5+
######################################################
6+
7+
{vhost_port_listen} Listen {apps_vhost_port}
8+
NameVirtualHost *:{apps_vhost_port}
9+
10+
<VirtualHost {apps_vhost_ip}:{apps_vhost_port}>
11+
ServerAdmin webmaster@localhost
12+
{apps_vhost_servername}
13+
14+
<IfModule mod_fcgid.c>
15+
DocumentRoot {apps_vhost_dir}
16+
SuexecUserGroup ispapps ispapps
17+
<Directory {apps_vhost_dir}>
18+
Options Indexes FollowSymLinks MultiViews +ExecCGI
19+
AllowOverride AuthConfig Indexes Limit Options FileInfo
20+
AddHandler fcgid-script .php
21+
FCGIWrapper /var/www/php-fcgi-scripts/apps/.php-fcgi-starter .php
22+
Order allow,deny
23+
Allow from all
24+
</Directory>
25+
</IfModule>
26+
27+
<IfModule mod_php5.c>
28+
DocumentRoot {apps_vhost_dir}
29+
AddType application/x-httpd-php .php
30+
<Directory {apps_vhost_dir}>
31+
Options FollowSymLinks
32+
AllowOverride None
33+
Order allow,deny
34+
Allow from all
35+
</Directory>
36+
</IfModule>
37+
38+
ServerSignature Off
39+
40+
</VirtualHost>
41+
42+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
PHPRC=/etc/php5/cgi/
3+
export PHPRC
4+
export PHP_FCGI_MAX_REQUESTS=5000
5+
export PHP_FCGI_CHILDREN=1
6+
exec /usr/lib/cgi-bin/php -d magic_quotes_gpc=off

install/tpl/apache_ispconfig_fcgi_starter.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
PHPRC=/etc/php5/cgi/
33
export PHPRC
44
export PHP_FCGI_MAX_REQUESTS=5000
5-
export PHP_FCGI_CHILDREN=8
5+
export PHP_FCGI_CHILDREN=1
66
exec /usr/lib/cgi-bin/php -d magic_quotes_gpc=off

0 commit comments

Comments
 (0)