summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-09-18 20:36:16 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-09-18 20:36:16 +0000
commit4edb490df2e2f054374a710c5d8871c76cbebe27 (patch)
tree38e6ac4b726690ba4a0f77a886edb2a66cb67931 /etc
parent997c3b7a33cd7463f0e84874fee8e6262fa6f608 (diff)
downloadpfsense-4edb490df2e2f054374a710c5d8871c76cbebe27.zip
pfsense-4edb490df2e2f054374a710c5d8871c76cbebe27.tar.gz
Turn off fast cgi on memory strapped systems
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/captiveportal.inc4
-rw-r--r--etc/inc/system.inc78
2 files changed, 57 insertions, 25 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 5eae073..1cbdef3 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -171,8 +171,10 @@ EOD;
/* get memory in meachine */
$memory = get_memory();
$avail = $memory[0];
+ $use_fastcgi = true;
if($avail > 0 and $avail < 65) {
$procs = 1;
+ $use_fastcgi = false;
} else if($avail > 64 and $avail < 128) {
$procs = 5;
} else if($avail > 128 and $avail < 164) {
@@ -192,7 +194,7 @@ EOD;
/* generate lighttpd configuration */
system_generate_lighty_config("{$g['varetc_path']}/lighty-CaptivePortal.conf",
$key, $cert, "lighty-CaptivePortal.pid", "8000", "/usr/local/captiveportal/",
- "cert-portal.pem", "5", $procs);
+ "cert-portal.pem", "5", $procs, $use_fastcgi);
/* attempt to start lighttpd */
$res = mwexec("/usr/local/sbin/lighttpd -f {$g['varetc_path']}/lighty-CaptivePortal.conf");
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 96766c2..016b90a 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -387,15 +387,23 @@ EOD;
}
/* non-standard port? */
- if ($config['system']['webgui']['port'])
+ if ($config['system']['webgui']['port'])
$port = $config['system']['webgui']['port'];
else
$port = "80";
+ /* if we are strapped for memory, do not use fast cgi */
+ $memory = get_memory();
+ $avail_mem = $memory[1];
+ if($avail < 128)
+ $use_fastcgi = false;
+ else
+ $use_fastcgi = true;
+
/* generate lighttpd configuration */
system_generate_lighty_config("{$g['varetc_path']}/lighty-webConfigurator.conf",
$key, $cert, "lighty-webConfigurator.pid", $port, "/usr/local/www/",
- "cert.pem", "1");
+ "cert.pem", "1", "1", $use_fastcgi);
/* attempt to start lighthttpd */
$res = mwexec("/usr/local/sbin/lighttpd -f {$g['varetc_path']}/lighty-webConfigurator.conf");
@@ -412,14 +420,49 @@ EOD;
function system_generate_lighty_config($filename, $cert, $key, $pid_file,
$port = "", $document_root = "/usr/local/www/",
- $cert_location = "cert.pem",
- $max_procs, $max_requests = "1") {
+ $cert_location = "cert.pem", $max_procs,
+ $max_requests = "1", $fast_cgi_enable = true) {
if($port <> "")
$lighty_port = $port;
else
$lighty_port = "80";
+ if($fast_cgi_enable == true) {
+ $module = "\"mod_fastcgi\"";
+ $cgi_config = "";
+ $fastcgi_config = <<<EOD
+#### fastcgi module
+## read fastcgi.txt for more info
+fastcgi.server = ( ".php" =>
+ ( "localhost" =>
+ (
+ "socket" => "/tmp/php-fastcgi.socket",
+ "min-procs" => 1,
+ "max-procs" => {$max_procs},
+ "max-load-per-proc" => 1,
+ "idle-timeout" => 1,
+ "bin-environment" => (
+ "PHP_FCGI_CHILDREN" => "{$max_procs}",
+ "PHP_FCGI_MAX_REQUESTS" => "{$max_requests}"
+ ),
+ "bin-path" => "/usr/local/bin/php"
+ )
+ )
+ )
+
+EOD;
+ } else {
+ $fastcgi_config = "";
+ $module = "\"mod_cgi\"";
+ $cgi_config = <<<EOD
+#### CGI module
+cgi.assign = ( ".php" => "/usr/local/bin/php",
+ ".cgi" => "/usr/bin/perl" )
+
+EOD;
+ }
+
$lighty_config .= <<<EOD
#
# lighttpd configuration file
@@ -429,8 +472,10 @@ function system_generate_lighty_config($filename, $cert, $key, $pid_file,
############ Options you really have to take care of ####################
## modules to load
-server.modules = ("mod_access",
- "mod_fastcgi")
+server.modules = (
+ "mod_access",
+ {$module}
+ )
## Unused modules
# "mod_setenv",
@@ -555,24 +600,9 @@ debug.log-file-not-found = "disable"
#compress.cache-dir = "/tmp/lighttpd/cache/compress/"
#compress.filetype = ("text/plain", "text/html")
-#### fastcgi module
-## read fastcgi.txt for more info
-fastcgi.server = ( ".php" =>
- ( "localhost" =>
- (
- "socket" => "/tmp/php-fastcgi.socket",
- "min-procs" => 1,
- "max-procs" => {$max_procs},
- "max-load-per-proc" => 1,
- "idle-timeout" => 1,
- "bin-environment" => (
- "PHP_FCGI_CHILDREN" => "{$max_procs}",
- "PHP_FCGI_MAX_REQUESTS" => "{$max_requests}"
- ),
- "bin-path" => "/usr/local/bin/php"
- )
- )
- )
+{$fastcgi_config}
+
+{$cgi_config}
EOD;
OpenPOWER on IntegriCloud