Lighttpd, sometimes pronounced “Lighty”, is a lightweight HTTP server that can help alleviate Apache’s load by serving static content. Since Lighttpd uses less resources per request than Apache, it generally serves most static content faster than Apache. This tutorial shows how to install Lighttpd behind Apache via ApacheÂ´s proxy module.
No guarantee that this will work for you!
To install such a system you will need the following:
- The Perfect Setup – Debian Etch (Debian 4.0)
- Installing Lighttpd With PHP5 And MySQL Support On Debian Etch
2 Setting up lighttpd
Once Lighttpd is installed, you’ll have to modify the configuration file to use it
#bind to port (Default: 80) server.port = 81 # bind to localhost (recommended for proxy behind Apache, otherwise comment this out for all) server.bind = "localhost"
This is not a full listing of the configuration file, but rather a highlight of the most important parts. Notice that we’ve set the server port to 81. By doing this, we’re making sure it doesn’t clash with Apache listening on port 80. If you wanted to let Lighttpd power your entire site instead of Apache, you can set this to port 80, or comment it out to accept the default.
Then we restart Lighttpd:
3 Setting up Apache’s proxy
To let Apache take the output of Lighttpd on port 81 and map it to your website, you’ll need to make sure the Proxy module of Apache is loaded.
Using the Perfect Setup tutorial this module will either be there already but not activated.
If you are using virtual hosting, you will want to use the following code to set up a proxy between the applicable
ProxyRequests Off ProxyPreserveHost On ProxyPass /media http://0.0.0.0:81/ ProxyPassReverse / http://0.0.0.0:81/
Then we restart Apache:
4 Final notice
In the above example, Lighttpd will serve up your media folder, leaving Apache to do the rest. Set this to any folder that has static content in it and Lighttpd will serve it, instead of Apache. Another good use of Lighttpd would be to serve up multimedia files, taking the load off of Apache. The increase of performance you’ll gain is dependent on many factors. If you only have Lighttpd serve up your images, it probably won’t help too much. You can put all of your static content, including HTML and PDF files, images, and movies in a folder called /static and then set the ProxyPass variable to that for a slightly better performance.
The increase of performance you’ve gained so far with Lighttpd is not phenomenal, but helps to increase the website performance and reduces the load on your server.
- Lighttpd: http://www.lighttpd.net
- Apache Module mod_proxy: http://httpd.apache.org/docs/2.0/mod/mod_proxy.html
- PHP: http://www.php.net
- MySQL: http://www.mysql.com
- Debian: http://www.debian.org