For those of you in a linux configuration you ought to take a serious look at lighttpd for your php5/moodle configuration. In my testing there is over a 50% performance gain with lighttpd over apache. I'd thought I would share my configuration for my moodle setup using debian lenny or ubuntu 8.0.4 LTS.
you can view the entire post on my blog - http://justinhaaga.wordpress.com/2009/06/18/apache2-fast-or-slow-try-lighttpd/
First, install the server (stop apache services if running or change to different port)
apt-get install lighttpd
apt-get install php5-cgi
Second, enable php
nano /etc/php5/cgi/php.ini
cgi.fix_path_info = 1
upload_max_filesize = 100M
post_max_size = 100
Third, enable php in lighthttpd
nano /etc/lighthttpd/lighthttpd.conf
nano /etc/lighthttpd/lighthttpd.conf
server.modules = (
“mod_access”,
“mod_alias”,
“mod_accesslog”,
“mod_compress”,
“mod_fastcgi
)
#add “mod_fastcgi” to the top as shown
##tweaks (depends on memory and CPU) so run some tests – max-proc and min-proc #specify how many php processes to spawn, make sure you adequately assign #according to memory, default is 2
server.max-connections = 250
server.max-fds = 625
fastcgi.server = ( “.php” => ((
“bin-path” => “/usr/bin/php5-cgi”,
“socket” => “/tmp/php.socket”,
“max-procs” => 4,
“min-procs” => 4,
“bin-environment” => (
“PHP_FCGI_CHILDREN” => “16″,
“PHP_FCGI_MAX_REQUESTS” => “10000″
),
“bin-copy-environment” => (
“PATH”, “SHELL”, “USER”
),
“broken-scriptfilename” => “enable”
)))
reset lighthttpd
/etc/init.d/lightttpd
DONE-now enjoy! default web root is /var/www
Extra-Need a SSL Cert? Here’s the config:
1. generate ssl cert using openssl (see other docs on the net)
2. mkdir /sslcerts cd /sslcerts
3. cat your.key your.crt > lms.pem
4. nano /etc/lighthttpd/lighthttpd.conf
$SERVER["socket"] == “10.10.13.161:443″ {
ssl.engine = “enable”
ssl.pemfile = “/sslcerts/.your.pem”
ssl.ca-file = “/sslcerts/your.crt”
server.name = “lms”
server.document-root = “/var/websites/lms/www”
server.errorlog = “/var/log/lighttpd/lmsserror.log”
accesslog.filename = “/var/log/lighttpd/lmsaccess.log”
}
Toggle on and off your apache and lighttpd (in a dev environment of course) and run through some apache bench tests as well as real time tests, you should find conclusion evidence that it's much faster. Full php configuration is supported so you will not need to add or change anything else other than above.