lighttpd: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
Line 3: Line 3:
Installation varies according to platform, so if the following example doesn't apply to your server configuration, check the official instruction page [http://trac.lighttpd.net/trac/wiki/TutorialInstallation here].  You will also need to install php (preferrably with an accelerator) and fast-cgi according to [http://trac.lighttpd.net/trac/wiki/TutorialLighttpdAndPHP these] instructions.
Installation varies according to platform, so if the following example doesn't apply to your server configuration, check the official instruction page [http://trac.lighttpd.net/trac/wiki/TutorialInstallation here].  You will also need to install php (preferrably with an accelerator) and fast-cgi according to [http://trac.lighttpd.net/trac/wiki/TutorialLighttpdAndPHP these] instructions.


It has been found to work well with PHP accelerators, for example [http://eaccelerator.net/ eAccelerator].
It has been found to work well with PHP accelerators like [http://eaccelerator.net/ eAccelerator] and [http://us2.php.net/apc Alternative PHP Cache (APC)].


One 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. Lighttpd will only let you specify folders to be cached.
One 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. Lighttpd will only let you specify folders to be cached.


===Fedora 6, 7, 8 & 9 Example===
===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 [http://us2.php.net/apc Alternative PHP Cache (APC)], using the following command.
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 a PHP accelerator [http://us2.php.net/apc APC] using the following command.
<pre>
<pre>
yum install lighttpd lighttpd-fastcgi mysql php php-mysql \
yum install lighttpd lighttpd-fastcgi mysql php php-mysql \
Line 28: 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.
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.
<pre>
<pre>
## modules to load
## modules to load
Line 37: Line 34:
#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 perceived response time, especially for 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 perceived response time, especially for distance learners and 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
# a comma may or may not be necessary depending on whether other active modules are listed after
"mod_compress"  
"mod_compress"  
# a comma may or may not be necessary depending on whether other modules are listed after
#### compress module
#### compress module
compress.cache-dir        = "/home/compress.tmp/"
compress.cache-dir        = "/home/compress.tmp/"
compress.filetype          = ("text/plain", "text/javascript", "text/css", "text/xml")
compress.filetype          = ("text/plain", "text/javascript", "text/css", "text/xml")
</pre>
</pre>
 
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).   
Second, edit /etc/php.ini to enable compression on the PHP output and increase the maximum server submission size (individual courses can still be limited below and up to this limit within Moodle itself).   
 
<pre>
<pre>
zlib.output_compression = On
zlib.output_compression = On
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 07:30, 10 January 2009

Lighttpd (a.k.a. Lighty) is a lightweight webserver with a small memory footprint. It is an alternative to Apache and IIS, particularly well suited to systems with low resources, especially RAM. Lighttpd is ideal for people using VPS hosting. Even on hosts with plenty of resources, Lighty is just as fast as Apache if not faster and well worth considering.

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.

It has been found to work well with PHP accelerators like eAccelerator and Alternative PHP Cache (APC).

One 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. Lighttpd will only let you specify folders to be cached.

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"
                                 )
                               )
                            )

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.

## 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 perceived response time, especially for 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
# a comma may or may not be necessary depending on whether other active modules are listed after
"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