diff --git a/install/install.php b/install/install.php index a8b772a3d465d87d2d937762e9205a4dbe1ded03..65a7f22e9e3cf385d9e1176cf14196148e697bd3 100644 --- a/install/install.php +++ b/install/install.php @@ -174,6 +174,23 @@ if($install_mode == 'Standard') { //* Configure ISPConfig swriteln('Installing ISPConfig'); + + //** We want to check if the server is a module or cgi based php enabled server + //** TODO: Don't always ask for this somehow ? + $fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no'); + + if($fast_cgi == 'yes') { + $alias = $inst->free_query('Script Alias', '/php/'); + $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin'); + $inst->conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path); + } else { + $inst->conf['apache']['vhost_cgi_alias'] = ""; + } + + + //** Customise the port ISPConfig runs on + $inst->conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080'); + $inst->install_ispconfig(); //* Configure ISPConfig diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index daef564b446134d8f9e05ca3c2c5d986f1e1217d..cad13a5ba4925accfce41bc51f9ff730f0382037 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -691,7 +691,17 @@ class installer_base { // TODO: These are missing! should they be "vhost_dist_*_dir" ? $vhost_conf_dir = $this->conf['apache']['vhost_conf_dir']; $vhost_conf_enabled_dir = $this->conf['apache']['vhost_conf_enabled_dir']; - copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost"); + + + // Dont just copy over the virtualhost template but add some custom settings + + $content = rf("tpl/apache_ispconfig.vhost.master"); + $content = str_replace('{vhost_port}', $this->conf['apache']['vhost_port'], $content); + $content = str_replace('{vhost_cgi_alias}', $this->conf['apache']['vhost_cgi_alias'], $content); + + wf("$vhost_conf_dir/ispconfig.vhost", $content); + + //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost"); //* and create the symlink if(!is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) { exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/ispconfig.vhost"); diff --git a/install/tpl/apache_ispconfig.vhost.master b/install/tpl/apache_ispconfig.vhost.master index 040d5eee4e6f998291d27bf95d8325f46523c949..f72676a36fca4b54dea752c008f92b749fe11151 100644 --- a/install/tpl/apache_ispconfig.vhost.master +++ b/install/tpl/apache_ispconfig.vhost.master @@ -4,13 +4,14 @@ # for the ISPConfig controlpanel ###################################################### -Listen 8080 -NameVirtualHost *:8080 +Listen {vhost_port} +NameVirtualHost *:{vhost_port} - + ServerAdmin webmaster@localhost DocumentRoot /usr/local/ispconfig/interface/web/ + {vhost_cgi_alias} AddType application/x-httpd-php .php diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index 3ec583e3071d53b2b0f122d847535745da8dee3a..5e66de107ce70acb74cb97ba68d68c6c19c278b0 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -31,4 +31,11 @@ getmail_config_dir=/etc/getmail website_path=/var/clients/client[client_id]/web[website_id] website_symlinks=/var/www/[website_domain]/:/var/clients/client[client_id]/[website_domain]/ vhost_conf_dir=/etc/apache2/sites-available -vhost_conf_enabled_dir=/etc/apache2/sites-enabled \ No newline at end of file +vhost_conf_enabled_dir=/etc/apache2/sites-enabled +fastcgi_starter_path=/var/www/php-fcgi-scripts/[system_user]/ +fastcgi_starter_script=.php-fcgi-starter +fastcgi_alias=/php/ +fastcgi_phpini_path=/etc/php5/cgi/ +fastcgi_children=8 +fastcgi_max_requests=5000 +fastcgi_bin=/usr/bin/php-cgi \ No newline at end of file diff --git a/install/update.php b/install/update.php index c05c00b9657e5ec89f91d183c197a376632e79d0..3c8c9366362dcb8d6165f83839a8e76622b6963d 100644 --- a/install/update.php +++ b/install/update.php @@ -174,6 +174,24 @@ if($reconfigure_services_answer == 'yes') { //** Configure ISPConfig swriteln('Updating ISPConfig'); + + +//** We want to check if the server is a module or cgi based php enabled server +//** TODO: Don't always ask for this somehow ? +$fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no'); + +if($fast_cgi == 'yes') { + $alias = $inst->free_query('Script Alias', '/php/'); + $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin'); + $inst->conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path); +} else { + $inst->conf['apache']['vhost_cgi_alias'] = ""; +} + + +//** Customise the port ISPConfig runs on +$inst->conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080'); + $inst->install_ispconfig(); //** Configure Crontab diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index 2670de726a3e86d08f8c112400a5d5ca60254e9b..8bf89c427c674ddea5da39157991b3044357c8f9 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -154,7 +154,6 @@ class page_action extends tform_actions { } $app->tpl->setVar("client_group_id",$client_select); - } parent::onShowEnd(); diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master index 0d6f14ebfc9fc22c6344c0e36c0c91e1a78cb286..220570ed239d19e83a78f012b564c0007df57396 100644 --- a/server/conf/vhost.conf.master +++ b/server/conf/vhost.conf.master @@ -46,6 +46,12 @@ # php as cgi enabled AddType application/x-httpd-php .php .php3 .php4 .php5 + + # php as fast-cgi enabled + AddType application/x-httpd-php .php .php3 .php4 .php5 + + ScriptAlias + RewriteEngine on diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index d084d7b6065243f6bdb362d65a68f050005d061a..445f30edfe882373852e22c4bc3f5fe068f5e372 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -374,6 +374,43 @@ class apache2_plugin { } $tpl->setLoop('redirects',$rewrite_rules); + /** + * install fast-cgi starter script and add script aliasd config + * first we create the script directory if not already created, then copy over the starter script + * settings are copied over from the server ini config for now + * TODO: Create form for fastcgi configs per site. + */ + + if ($data["new"]["php"] == "fast-cgi") + { + $fastcgi_starter_path = str_replace("[system_user]",$data["new"]["system_user"],$web_config["fastcgi_starter_path"]); + if (!is_dir($fastcgi_starter_path)) + { + exec("mkdir $fastcgi_starter_path"); + exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fastcgi_starter_path"); + } + + $fcgi_tpl = new tpl(); + $fcgi_tpl->newTemplate("php-fcgi-starter.master"); + + $fcgi_tpl->setVar('php_ini_path',$web_config["fastcgi_phpini_path"]); + $fcgi_tpl->setVar('document_root',$data["new"]["document_root"]); + $fcgi_tpl->setVar('php_fcgi_children',$web_config["fastcgi_children"]); + $fcgi_tpl->setVar('php_fcgi_max_requests',$web_config["fastcgi_max_requests"]); + $fcgi_tpl->setVar('php_fcgi_bin',$web_config["fastcgi_bin"]); + + $fcgi_starter_script = escapeshellcmd($fastcgi_starter_path."/".$web_config["fastcgi_starter_script"]); + file_put_contents($fcgi_starter_script,$fcgi_tpl->grab()); + unset($fcgi_tpl); + + exec("chmod 755 $fcgi_starter_script"); + exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fcgi_starter_script"); + + $tpl->setVar('fastcgi_alias',$web_config["fastcgi_alias"]); + $tpl->setVar('fastcgi_starter_path',$fastcgi_starter_path); + + } + $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["new"]["domain"].'.vhost'); file_put_contents($vhost_file,$tpl->grab()); $app->log("Writing the vhost file: $vhost_file",LOGLEVEL_DEBUG);