Note: You are currently viewing documentation for Moodle 2.6. Up-to-date documentation for the latest stable version of Moodle may be available here: lighttpd.

lighttpd

From MoodleDocs

Lighttpd (a.k.a. Lighty) is a lightweight webserver with a small memory footprint that works well with PHP accelerators like eAccelerator and Alternative PHP Cache (APC). It is an alternative to Apache and IIS particularly well suited to systems with low resources, especially RAM -- ideal when using virtual private server (VPS) hosting services. Even on hosts with plenty of resources, Lighty is as fast as Apache if not faster and worth considering.

Lighttpd meets all the base requirements for Moodle and provides most common webserving features; however, it is not intended to replace Apache feature for feature. If your needs extend further than Moodle, be aware of lighttpd's differences and limitations as well as level of knowledge and support necessary and available. Be certain it meets all of your needs before deploying in a production environment.

Installation varies according to platform, if the following example doesn't apply to your server configuration, check the official instruction page here. You will also need to install PHP (preferably with an accelerator) and FastCGI according to these instructions.

Fedora 9, 10 & 11 Example

Lighttpd is a part of the official repository and can be installed using yum to meet all of Moodle's base requirements, including the PHP accelerator Alternative PHP Cache (APC), using the following command.

yum install lighttpd lighttpd-fastcgi mysql php php-mysql \
php-pecl-apc php-gd php-mbstring php-xmlrpc php-pdo ;

Under the respective sections, edit /etc/lighttpd/lighttpd.conf to point to the Moodle root directory, uncomment the FastCGI module and the fastcgi module section; be sure the bin-path points to the PHP FastCGI executable:

## modules to load
# NOTE: a comma (,) is necessary when other active modules follow this one,
# unnecessary when this is the final active module in the server.modules directive
"mod_fastcgi",
## a static document-root example
server.document-root        = "/home/moodle-1.9/"
#### fastcgi module
fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => "/tmp/php-fastcgi.socket",
                                   "bin-path" => "/usr/bin/php-cgi"
                                 )
                               )
                            )

Client cache control and expiry is very flexible, uncomment the expiration module directive and add the following into /etc/lighttpd/lighttpd.conf for expiry control of common types of static files, change the number of days to meet your needs.

## modules to load
# Module load order is important, the mod_expire should be listed before mod_compress when both are active.
# NOTE: a comma (,) is necessary when other active modules follow this one,
# unnecessary when this is the final active module in the server.modules directive
"mod_expire",
## Client cache control section.
# mod_expire - image files expire 2 days after first access
$HTTP["url"] =~ "\.(gif|GIF|jpg|JPG|png|PNG|swf|SWF|ico|ICO)$" {
     expire.url = ( "" => "access 2 days" )
}
# mod_expire - includes expire 1 day after first access
$HTTP["url"] =~ "\.(css|CSS|js|JS)$" {
     expire.url = ( "" => "access 1 days" )
}
# Some versions of lighttpd may require the following directives for full functionality, uncomment if needed.
# etag.use-inode = "enable"
# etag.use-mtime = "enable"
# etag.use-size = "enable"
# static-file.etags = "enable"

Since Moodle maintains its own logs and reporting tools, you can disable lighttpd's server-level logging by commenting out the following lines in /etc/lighttpd/lighttpd.conf, as follows under the respective sections.

## modules to load
# NOTE: a comma (,) is necessary when other active modules follow this one,
# unnecessary when this is the final active module in the server.modules directive
# "mod_accesslog"
#### accesslog module
#accesslog.filename          = "/var/log/lighttpd/access_log"

If your server has CPU cycles to spare, enabling compression improves network speed and students' perceived response time, especially for off-campus and distance learners. Compression should be separated at the HTTP and PHP levels to maximize CPU cycles (especially on multiple-CPU and multi-core systems). First uncomment the compression module in /etc/lighttpd/lighttpd.conf, create a directory for the compressed file temporary store (in this example, it's /tmp/compress.tmp) and enter it along with the types of files to compress (do not include PHP mimetypes here), as follows under the respective sections:

## modules to load
# NOTE: a comma (,) is necessary when other active modules follow this one,
# unnecessary when this is the final active module in the server.modules directive
"mod_compress"
#### compress module
compress.cache-dir         = "/tmp/compress.tmp/"
compress.filetype          = ("text/plain", "text/javascript", "text/css", "text/xml")

Second, edit /etc/php.ini to enable compression on the PHP output and consider increasing the maximum server submission size (individual courses can still be limited lower than and up to this limit within Moodle itself, if needed).

zlib.output_compression = On
post_max_size = 32M

Finally, the standard memory pool setting of 32MB for Alternative PHP Cache (APC) is fairly low for Moodle, edit /etc/php.d/apc.ini and increase it to 64 or 128 depending on server load and total available memory. Increasing this setting can increase the speed of page generation made from within the opcode cache on even modest equipment.

apc.shm_size=128

See Also