Skip to content

Commit 99b55bf

Browse files
committed
- nginx: If apps vhost is reconfigured, apps pool (PHP-FPM) is reconfigured as well.
- Installer adds Apache and nginx user to ispapps group. - Installer makes sure that /var/www/apps has 755 permissions.
1 parent ca0b77f commit 99b55bf

File tree

6 files changed

+62
-5
lines changed

6 files changed

+62
-5
lines changed

install/dist/lib/fedora.lib.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,17 @@ public function install_ispconfig()
857857
if($conf['apache']['installed'] == true){
858858
$command = 'usermod -a -G ispconfig '.$conf['apache']['user'];
859859
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
860+
$command = 'usermod -a -G ispapps '.$conf['apache']['user'];
861+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
860862
}
861863
if($conf['nginx']['installed'] == true){
862864
$command = 'usermod -a -G ispconfig '.$conf['nginx']['user'];
863865
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
864866
// Allow the ispapps vhost access to /etc/squirrelmail
865867
$command = 'usermod -a -G '.$conf['apache']['group'].' ispapps';
866868
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
869+
$command = 'usermod -a -G ispapps '.$conf['nginx']['user']';
870+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
867871
}
868872

869873
//* Make the shell scripts executable

install/dist/lib/gentoo.lib.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,10 @@ public function configure_apps_vhost()
572572
$command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
573573
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
574574

575-
if (!@is_dir($install_dir)) {
575+
if(!@is_dir($install_dir)){
576576
mkdir($install_dir, 0755, true);
577+
} else {
578+
chmod($install_dir, 0755);
577579
}
578580
chown($install_dir, $apps_vhost_user);
579581
chgrp($install_dir, $apps_vhost_group);
@@ -864,10 +866,14 @@ public function install_ispconfig()
864866
if($conf['apache']['installed'] == true){
865867
$command = 'usermod -a -G ispconfig '.$conf['apache']['user'];
866868
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
869+
$command = 'usermod -a -G ispapps '.$conf['apache']['user'];
870+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
867871
}
868872
if($conf['nginx']['installed'] == true){
869873
$command = 'usermod -a -G ispconfig '.$conf['nginx']['user'];
870874
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
875+
$command = 'usermod -a -G ispapps '.$conf['nginx']['user'];
876+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
871877
}
872878

873879
//* Make the shell scripts executable

install/dist/lib/opensuse.lib.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,10 +894,14 @@ public function install_ispconfig()
894894
if($conf['apache']['installed'] == true){
895895
$command = 'groupmod --add-user '.$conf['apache']['user'].' ispconfig';
896896
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
897+
$command = 'groupmod --add-user '.$conf['apache']['user'].' ispapps';
898+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
897899
}
898900
if($conf['nginx']['installed'] == true){
899901
$command = 'groupmod --add-user '.$conf['nginx']['user'].' ispconfig';
900902
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
903+
$command = 'groupmod --add-user '.$conf['nginx']['user'].' ispapps';
904+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
901905
}
902906

903907
//* Make the shell scripts executable

install/lib/installer_base.lib.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,11 @@ public function configure_apps_vhost() {
13961396
$command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
13971397
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
13981398

1399-
if(!@is_dir($install_dir)) mkdir($install_dir, 0755, true);
1399+
if(!@is_dir($install_dir)){
1400+
mkdir($install_dir, 0755, true);
1401+
} else {
1402+
chmod($install_dir, 0755);
1403+
}
14001404
chown($install_dir, $apps_vhost_user);
14011405
chgrp($install_dir, $apps_vhost_group);
14021406

@@ -1744,10 +1748,14 @@ public function install_ispconfig() {
17441748
if($conf['apache']['installed'] == true){
17451749
$command = 'adduser '.$conf['apache']['user'].' ispconfig';
17461750
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
1751+
$command = 'adduser '.$conf['apache']['user'].' ispapps';
1752+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
17471753
}
17481754
if($conf['nginx']['installed'] == true){
17491755
$command = 'adduser '.$conf['nginx']['user'].' ispconfig';
17501756
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
1757+
$command = 'adduser '.$conf['nginx']['user'].' ispapps';
1758+
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
17511759
}
17521760

17531761
//* Make the shell scripts executable
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[{fpm_pool}]
2+
3+
listen = {fpm_socket}
4+
listen.owner = {fpm_user}
5+
listen.group = {fpm_group}
6+
listen.mode = 0660
7+
8+
user = {fpm_user}
9+
group = {fpm_group}
10+
11+
pm = dynamic
12+
pm.max_children = 50
13+
pm.start_servers = 20
14+
pm.min_spare_servers = 5
15+
pm.max_spare_servers = 35
16+
17+
chdir = /
18+
19+
php_admin_flag[magic_quotes_gpc] = off

server/plugins-available/apps_vhost_plugin.inc.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ function update($event_name,$data) {
9999
} else {
100100
$content = str_replace('{vhost_port_listen}', '', $content);
101101
}
102+
103+
file_put_contents("$vhost_conf_dir/apps.vhost", $content);
104+
$app->services->restartServiceDelayed('httpd','restart');
102105
}
103106

104107
if($web_config['server_type'] == 'nginx'){
@@ -108,6 +111,9 @@ function update($event_name,$data) {
108111
$vhost_conf_dir = $web_config['nginx_vhost_conf_dir'];
109112
$vhost_conf_enabled_dir = $web_config['nginx_vhost_conf_enabled_dir'];
110113
$apps_vhost_servername = ($web_config['apps_vhost_servername'] == '')?'_':$web_config['apps_vhost_servername'];
114+
115+
$apps_vhost_user = 'ispapps';
116+
$apps_vhost_group = 'ispapps';
111117

112118
$web_config['apps_vhost_port'] = (empty($web_config['apps_vhost_port']))?8081:$web_config['apps_vhost_port'];
113119
$web_config['apps_vhost_ip'] = (empty($web_config['apps_vhost_ip']))?'_default_':$web_config['apps_vhost_ip'];
@@ -129,10 +135,20 @@ function update($event_name,$data) {
129135
$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
130136
//$content = str_replace('{fpm_port}', $web_config['php_fpm_start_port']+1, $content);
131137
$content = str_replace('{fpm_socket}', $fpm_socket, $content);
138+
139+
// PHP-FPM
140+
// Dont just copy over the php-fpm pool template but add some custom settings
141+
$fpm_content = file_get_contents($conf["rootpath"]."/conf/apps_php_fpm_pool.conf.master");
142+
$fpm_content = str_replace('{fpm_pool}', 'apps', $fpm_content);
143+
//$fpm_content = str_replace('{fpm_port}', $web_config['php_fpm_start_port']+1, $fpm_content);
144+
$fpm_content = str_replace('{fpm_socket}', $fpm_socket, $fpm_content);
145+
$fpm_content = str_replace('{fpm_user}', $apps_vhost_user, $fpm_content);
146+
$fpm_content = str_replace('{fpm_group}', $apps_vhost_group, $fpm_content);
147+
file_put_contents($web_config['php_fpm_pool_dir'].'/apps.conf', $fpm_content);
148+
149+
file_put_contents("$vhost_conf_dir/apps.vhost", $content);
150+
$app->services->restartServiceDelayed('httpd','reload');
132151
}
133-
134-
file_put_contents("$vhost_conf_dir/apps.vhost", $content);
135-
$app->services->restartServiceDelayed('httpd','restart');
136152
}
137153

138154

0 commit comments

Comments
 (0)