Skip to content

Commit 9b9ba42

Browse files
author
daniel
committed
1 parent 8a05d76 commit 9b9ba42

File tree

8 files changed

+101
-6
lines changed

8 files changed

+101
-6
lines changed

install/install.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,23 @@
174174

175175
//* Configure ISPConfig
176176
swriteln('Installing ISPConfig');
177+
178+
//** We want to check if the server is a module or cgi based php enabled server
179+
//** TODO: Don't always ask for this somehow ?
180+
$fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
181+
182+
if($fast_cgi == 'yes') {
183+
$alias = $inst->free_query('Script Alias', '/php/');
184+
$path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
185+
$inst->conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
186+
} else {
187+
$inst->conf['apache']['vhost_cgi_alias'] = "";
188+
}
189+
190+
191+
//** Customise the port ISPConfig runs on
192+
$inst->conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
193+
177194
$inst->install_ispconfig();
178195

179196
//* Configure ISPConfig

install/lib/installer_base.lib.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,17 @@ public function install_ispconfig()
691691
// TODO: These are missing! should they be "vhost_dist_*_dir" ?
692692
$vhost_conf_dir = $this->conf['apache']['vhost_conf_dir'];
693693
$vhost_conf_enabled_dir = $this->conf['apache']['vhost_conf_enabled_dir'];
694-
copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
694+
695+
696+
// Dont just copy over the virtualhost template but add some custom settings
697+
698+
$content = rf("tpl/apache_ispconfig.vhost.master");
699+
$content = str_replace('{vhost_port}', $this->conf['apache']['vhost_port'], $content);
700+
$content = str_replace('{vhost_cgi_alias}', $this->conf['apache']['vhost_cgi_alias'], $content);
701+
702+
wf("$vhost_conf_dir/ispconfig.vhost", $content);
703+
704+
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
695705
//* and create the symlink
696706
if(!is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) {
697707
exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/ispconfig.vhost");

install/tpl/apache_ispconfig.vhost.master

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
# for the ISPConfig controlpanel
55
######################################################
66

7-
Listen 8080
8-
NameVirtualHost *:8080
7+
Listen {vhost_port}
8+
NameVirtualHost *:{vhost_port}
99

10-
<VirtualHost _default_:8080>
10+
<VirtualHost _default_:{vhost_port}>
1111
ServerAdmin webmaster@localhost
1212
DocumentRoot /usr/local/ispconfig/interface/web/
1313

14+
{vhost_cgi_alias}
1415
<IfModule mod_php5.c>
1516
AddType application/x-httpd-php .php
1617
</IfModule>

install/tpl/server.ini.master

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,11 @@ getmail_config_dir=/etc/getmail
3131
website_path=/var/clients/client[client_id]/web[website_id]
3232
website_symlinks=/var/www/[website_domain]/:/var/clients/client[client_id]/[website_domain]/
3333
vhost_conf_dir=/etc/apache2/sites-available
34-
vhost_conf_enabled_dir=/etc/apache2/sites-enabled
34+
vhost_conf_enabled_dir=/etc/apache2/sites-enabled
35+
fastcgi_starter_path=/var/www/php-fcgi-scripts/[system_user]/
36+
fastcgi_starter_script=.php-fcgi-starter
37+
fastcgi_alias=/php/
38+
fastcgi_phpini_path=/etc/php5/cgi/
39+
fastcgi_children=8
40+
fastcgi_max_requests=5000
41+
fastcgi_bin=/usr/bin/php-cgi

install/update.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,24 @@
174174

175175
//** Configure ISPConfig
176176
swriteln('Updating ISPConfig');
177+
178+
179+
//** We want to check if the server is a module or cgi based php enabled server
180+
//** TODO: Don't always ask for this somehow ?
181+
$fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
182+
183+
if($fast_cgi == 'yes') {
184+
$alias = $inst->free_query('Script Alias', '/php/');
185+
$path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
186+
$inst->conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
187+
} else {
188+
$inst->conf['apache']['vhost_cgi_alias'] = "";
189+
}
190+
191+
192+
//** Customise the port ISPConfig runs on
193+
$inst->conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
194+
177195
$inst->install_ispconfig();
178196

179197
//** Configure Crontab

interface/web/sites/web_domain_edit.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ function onShowEnd() {
154154
}
155155
$app->tpl->setVar("client_group_id",$client_select);
156156

157-
158157
}
159158

160159
parent::onShowEnd();

server/conf/vhost.conf.master

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
# php as cgi enabled
4747
AddType application/x-httpd-php .php .php3 .php4 .php5
4848
</tmpl_if>
49+
<tmpl_if name='php' op='==' value='fast-cgi'>
50+
# php as fast-cgi enabled
51+
AddType application/x-httpd-php .php .php3 .php4 .php5
52+
53+
ScriptAlias <tmpl_var name='fastcgi_alias'> <tmpl_var name='fastcgi_starter_path'>
54+
</tmpl_if>
4955

5056
<tmpl_if name="rewrite_enabled">
5157
RewriteEngine on

server/plugins-available/apache2_plugin.inc.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,43 @@ function update($event_name,$data) {
374374
}
375375
$tpl->setLoop('redirects',$rewrite_rules);
376376

377+
/**
378+
* install fast-cgi starter script and add script aliasd config
379+
* first we create the script directory if not already created, then copy over the starter script
380+
* settings are copied over from the server ini config for now
381+
* TODO: Create form for fastcgi configs per site.
382+
*/
383+
384+
if ($data["new"]["php"] == "fast-cgi")
385+
{
386+
$fastcgi_starter_path = str_replace("[system_user]",$data["new"]["system_user"],$web_config["fastcgi_starter_path"]);
387+
if (!is_dir($fastcgi_starter_path))
388+
{
389+
exec("mkdir $fastcgi_starter_path");
390+
exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fastcgi_starter_path");
391+
}
392+
393+
$fcgi_tpl = new tpl();
394+
$fcgi_tpl->newTemplate("php-fcgi-starter.master");
395+
396+
$fcgi_tpl->setVar('php_ini_path',$web_config["fastcgi_phpini_path"]);
397+
$fcgi_tpl->setVar('document_root',$data["new"]["document_root"]);
398+
$fcgi_tpl->setVar('php_fcgi_children',$web_config["fastcgi_children"]);
399+
$fcgi_tpl->setVar('php_fcgi_max_requests',$web_config["fastcgi_max_requests"]);
400+
$fcgi_tpl->setVar('php_fcgi_bin',$web_config["fastcgi_bin"]);
401+
402+
$fcgi_starter_script = escapeshellcmd($fastcgi_starter_path."/".$web_config["fastcgi_starter_script"]);
403+
file_put_contents($fcgi_starter_script,$fcgi_tpl->grab());
404+
unset($fcgi_tpl);
405+
406+
exec("chmod 755 $fcgi_starter_script");
407+
exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fcgi_starter_script");
408+
409+
$tpl->setVar('fastcgi_alias',$web_config["fastcgi_alias"]);
410+
$tpl->setVar('fastcgi_starter_path',$fastcgi_starter_path);
411+
412+
}
413+
377414
$vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["new"]["domain"].'.vhost');
378415
file_put_contents($vhost_file,$tpl->grab());
379416
$app->log("Writing the vhost file: $vhost_file",LOGLEVEL_DEBUG);

0 commit comments

Comments
 (0)