diff --git a/install/dist/conf/centos52.conf.php b/install/dist/conf/centos52.conf.php index 165de932f71835c608c15a774c0f665e4b1fd7d9..5d1216be2e4285d4b9a665f96f60072236b86fe5 100644 --- a/install/dist/conf/centos52.conf.php +++ b/install/dist/conf/centos52.conf.php @@ -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]/'; diff --git a/install/dist/conf/centos53.conf.php b/install/dist/conf/centos53.conf.php index 165de932f71835c608c15a774c0f665e4b1fd7d9..5d1216be2e4285d4b9a665f96f60072236b86fe5 100644 --- a/install/dist/conf/centos53.conf.php +++ b/install/dist/conf/centos53.conf.php @@ -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]/'; diff --git a/install/dist/conf/debian40.conf.php b/install/dist/conf/debian40.conf.php index d75729a9233b801fa7313e7c1be0a5a90ab1d6aa..cdfdb26f27c3be8ce4381dc0190173f923551eff 100644 --- a/install/dist/conf/debian40.conf.php +++ b/install/dist/conf/debian40.conf.php @@ -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]/'; diff --git a/install/dist/conf/fedora9.conf.php b/install/dist/conf/fedora9.conf.php index 4211732386fd64a904c3ee8f4a24ff52195401b8..0ab5a0ba79e8044576bf30ab5e22cf9b084e6cab 100644 --- a/install/dist/conf/fedora9.conf.php +++ b/install/dist/conf/fedora9.conf.php @@ -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]/'; diff --git a/install/dist/conf/opensuse110.conf.php b/install/dist/conf/opensuse110.conf.php index af704a32edbbce49831214708d374d515b9a2138..8c40a8813ad4f3470a3ecfc11dae103240fcbb68 100644 --- a/install/dist/conf/opensuse110.conf.php +++ b/install/dist/conf/opensuse110.conf.php @@ -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]/'; diff --git a/install/install.php b/install/install.php index b870f5309a5eaedd38e9176c02e6072783ea129e..544902898dedf051bd6aa2f6db021a618c224d26 100644 --- a/install/install.php +++ b/install/install.php @@ -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 diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index f489e087afc124212e35cfc73921cbab9e3afe76..93b28abef6cd9fa70cbac7901c6fb601a4a7f1bb 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -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() { diff --git a/install/tpl/apache_apps.vhost.master b/install/tpl/apache_apps.vhost.master new file mode 100644 index 0000000000000000000000000000000000000000..ceb9c3a3e41e5c8bdcbbf5702ff24c582c42b7de --- /dev/null +++ b/install/tpl/apache_apps.vhost.master @@ -0,0 +1,42 @@ + +###################################################### +# This virtual host contains the configuration +# for the ISPConfig apps vhost +###################################################### + +{vhost_port_listen} Listen {apps_vhost_port} +NameVirtualHost *:{apps_vhost_port} + + + ServerAdmin webmaster@localhost + {apps_vhost_servername} + + + DocumentRoot {apps_vhost_dir} + SuexecUserGroup ispapps ispapps + + 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 + + + + + DocumentRoot {apps_vhost_dir} + AddType application/x-httpd-php .php + + Options FollowSymLinks + AllowOverride None + Order allow,deny + Allow from all + + + + ServerSignature Off + + + + diff --git a/install/tpl/apache_apps_fcgi_starter.master b/install/tpl/apache_apps_fcgi_starter.master new file mode 100644 index 0000000000000000000000000000000000000000..a638732da9b4aedd59ba675e4dc9f175d7ea5b3f --- /dev/null +++ b/install/tpl/apache_apps_fcgi_starter.master @@ -0,0 +1,6 @@ +#!/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 diff --git a/install/tpl/apache_ispconfig_fcgi_starter.master b/install/tpl/apache_ispconfig_fcgi_starter.master index 1d7262a573b0b26e69e8d1d8f5dcbb865e3c738d..a638732da9b4aedd59ba675e4dc9f175d7ea5b3f 100644 --- a/install/tpl/apache_ispconfig_fcgi_starter.master +++ b/install/tpl/apache_ispconfig_fcgi_starter.master @@ -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 diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index 551e2b3f615ad37ee0e36e103518e8f472b72f1f..9cc4e6f144fd90feb833043fe6e3bd5376d74cb8 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -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]/ diff --git a/install/update.php b/install/update.php index 08a2fb257cd2ec3728b8ebed98a0493f4e2fa2eb..01158e6e7ac55bedb5a4e1f629f814a342120171 100644 --- a/install/update.php +++ b/install/update.php @@ -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(); } diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index a522c4cf9c8781b83a313bb0fe8bf5b32ad4ed83..feeeb6fda623669488b18e4c823c3775f8abf3f8 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -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 ################################## diff --git a/interface/web/admin/templates/server_config_web_edit.htm b/interface/web/admin/templates/server_config_web_edit.htm index 646c0765e0d94122548d7b69abe80e45eebcba55..ca1c3aed90b73597cdc351f2433d3aecd6f064ce 100644 --- a/interface/web/admin/templates/server_config_web_edit.htm +++ b/interface/web/admin/templates/server_config_web_edit.htm @@ -40,7 +40,19 @@
-
+ +
+ + +
+
+ + +
+
+ + +
diff --git a/server/conf/apache_apps.vhost.master b/server/conf/apache_apps.vhost.master new file mode 100644 index 0000000000000000000000000000000000000000..ceb9c3a3e41e5c8bdcbbf5702ff24c582c42b7de --- /dev/null +++ b/server/conf/apache_apps.vhost.master @@ -0,0 +1,42 @@ + +###################################################### +# This virtual host contains the configuration +# for the ISPConfig apps vhost +###################################################### + +{vhost_port_listen} Listen {apps_vhost_port} +NameVirtualHost *:{apps_vhost_port} + + + ServerAdmin webmaster@localhost + {apps_vhost_servername} + + + DocumentRoot {apps_vhost_dir} + SuexecUserGroup ispapps ispapps + + 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 + + + + + DocumentRoot {apps_vhost_dir} + AddType application/x-httpd-php .php + + Options FollowSymLinks + AllowOverride None + Order allow,deny + Allow from all + + + + ServerSignature Off + + + + diff --git a/server/plugins-available/apps_vhost_plugin.inc.php b/server/plugins-available/apps_vhost_plugin.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..b16778bef2672d2c477414ee3ccd6db3c36065de --- /dev/null +++ b/server/plugins-available/apps_vhost_plugin.inc.php @@ -0,0 +1,113 @@ +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