Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably available here: lighttpd.

lighttpd: Difference between revisions

From MoodleDocs
No edit summary
Line 27: Line 27:
                             )
                             )
</pre>
</pre>
Since Moodle maintains its own logs and reporting tools, you can disable lighttpd's server-level logging by commenting out (put a # mark in front of) the following lines in /etc/lighttpd/lighttpd.conf, as follows under the respective sections.
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.
<pre>
## modules to load
# Module load order is important, the mod_expire should be listed before mod_compress when both are active.
"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"
</pre>
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.
<pre>
<pre>
## modules to load
## modules to load
Line 34: Line 54:
#accesslog.filename          = "/var/log/lighttpd/access_log"
#accesslog.filename          = "/var/log/lighttpd/access_log"
</pre>
</pre>
If your server has CPU cycles to spare, enabling compression improves network speed and the student's 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 or 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 /home/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:
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 or 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 /home/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:
<pre>
<pre>
## modules to load
## modules to load
Line 49: Line 69:
post_max_size = 32M
post_max_size = 32M
</pre>
</pre>
==See Also==
==See Also==
* [http://tracker.moodle.org/browse/MDL-14638 Networking issue related to lighttpd]
* [http://tracker.moodle.org/browse/MDL-14638 Networking issue related to lighttpd]
* [http://en.wlmp-project.net/downloads.php WLMP project downloads for Windows packages]
* [http://en.wlmp-project.net/downloads.php WLMP project downloads for Windows packages]

Revision as of 19:03, 25 January 2009

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.

Note Lighttpd meets all the base requirements for Moodle and provides most of the 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. You are encouraged to be certain it meets all of your needs before deploying in a production environment.

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

A notable difference between Lighttpd and Apache is the expires directive that controls the caching of content. Apache allows you to set the expiry by file type, e.g. making a jpg image stay in the browser cache for a week, older versions of Lighttpd specify folders to be cached. Versions with ETag generation support provide full expiry mechanisms and control.

Fedora 6, 7, 8 & 9 Example

On the latest versions of Fedora, 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 ;

Edit /etc/lighttpd/lighttpd.conf to point to the Moodle root directory and the PHP-CGI area to activate and point to PHP's fastcgi executable, under the respective sections:

## 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.

## modules to load
# Module load order is important, the mod_expire should be listed before mod_compress when both are active.
"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
# "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 or 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 /home/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         = "/home/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

See Also