lighttpd

Basics

lighttpd (lighty) is a HTTP server designed to be light, efficient, secure and standards compliant. lighttpd is modular meaning the core of the server is only designed to provide the basic functions required of a HTTP server. There are a number of modules available to expand the functionality of lighttpd and provide interaction with various programming languages and database engines amongst other things.

Installation

lighttpd packages are available for most major distributions and can be installed using your distributions package manager.

apt-get (Debian based):

sudo apt-get install lighttpd

yum (Red Hat Based):

yum install lighttpd

If you have a distribution other than the ones covered please check their documentation on how to install packages. If your distribution does not provide a package you can find the source at http://www.lighttpd.net/download

Configuration

Virtual Hosts

Note: before proceeding, make sure that an A record already exists for the virtual host you wish to create

Virtual hosts within lighttpd are set up in your lighttpd.conf file, usually located at /etc/lighttpd/lighttpd.conf

Virtual host sections within lighttpd.conf will look like this:

 $HTTP["host"] == "sub.domain.com" {
 server.document-root = "/path/to/html/"
 }

With this applied, any request to sub.domain.com will use /path/to/html as the root of the virtual host. For example, requesting:

 http://sub.domain.com/files/index.php

Will tell lighttpd to parse /path/to/html/files/index.php as a web-requested file, exactly like the way pages are requested on the root domain.

The document-root for a virtual host does not have to be a subdirectory of your main host document-root, it can be any directory on the machine as long as that directory is web-server readable. However, to make maintenance easier it is best to have all virtual hosts (wherever possible) share the same parent directory.

You can also set up one directory to be the document-root for multiple virtual hosts using regular expressions:

 $HTTP["host"] =~ "(foo|bar)\.domain\.com" {
 server.document-root = "/path/to/html/"
 }

This will use /path/to/html/ as the document root for both foo.domain.com and bar.domain.com. Note the difference between the =~ and == operators. The former tells lighttpd to parse the virtual host as a regular expression, the latter is to parse the virtual host as a literal string.

For additional functionality, you can also combine modules within a virtual host section. For example, you can have each virtual host use its own mod_rewrite rules, use its own error pages and have individual access logs. Certain things, such as error pages, are inherited from the root host if they are not specified within the virtual host. Virtual hosts are, in essence, completely independent from the root host. This also allows a virtual host to be an entirely different domain, assuming the domain's nameservers are set correctly.

Finally, in order to apply any changes made to virtual hosts, you must restart lighttpd (as root):

 service lighttpd restart

Modules

PHP5

Before proceeding with this section please read PHP for installation and configuration details.

Once PHP5 is installed you need to enable the CGI module. To do this on a Debian based system the lighty-enable-mod command can be used.

sudo lighty-enable-mod cgi

MySQL

Before proceeding this section please read MySQL for installation and configuration details.p

 
web/lighttpd.txt · Last modified: 2008/10/18 17:36 by pete
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki