While a large proportion of the world's webservers are currently using Apache, a competitor has been steadily gaining popularity on many high-usage sites.
Lighttpd, pronounced "lighty", is a small-footprint, high-speed webserver, and is notably used by sites such as
Sourceforge,
YouTube and
MiniNova. Netcraft state that Lighttpd is currently being used on
1.38 million sites, and is steadily gaining on Sun's share of the market. This introductory article provides a guide to getting Lighttpd installed and configured.
Server statistics
Lighttpd can provide information on its status, configuration and usage statistics while running. This is done with mod_status. Append the following lines to the configuration file and restart the server:
server.modules += ( "mod_status" )
status.status-url = "/server-status"
status.config-url = "/server-config"
status.statistics-url = "/server-statistics"
You'll notice the
+= operator in the
server.modules line. This appends the new module to the list of server modules that are being loaded in at startup.
We should now be able to access these statistics at
http://your.server.name/server-status,
http://your.server.name/server-config and
http://your.server.name/server-statistics.
The above configuration allows this information to be accessible to anyone in the world, which isn't ideal. It's advisable to limit access to it to a small range of IP addresses. We'll see how to do this later, in the
Conditionals section.
User directories
If we were running a server for multiple users, such as in an educational institution, it's common for users to have their own homepages, typically in a
public_html subdirectory of their home directory.
mod_userdir is provided for this purpose. The following example enables user directories for all users except
root and
nobody:
server.modules += ( "mod_userdir" )
userdir.path = "public_html"
userdir.exclude-user = ( "root", "nobody" )
It's also possible to limit the users who can have a user directory, with the
userdir.include-user statement. If this is used, then only the listed users are allowed to have homepages:
userdir.include-user = ( "paul" )
Directory Listings
By default, if a directory doesn't have an index page, then the server will return a 404 error if the directory page is accessed. There are times when we might prefer to return a listing of the contents of the directory. This is done with the
mod_dirlisting module. This module is loaded into the server by default, however it still needs to be enabled:
dir-listing.activate = "enable"
If we didn't want any files that begin with a dot to be listed, then we could enable
dir-listing.hide-dotfiles:
dir-listing.hide-dotfiles = "enable"
Finally, we can display the contents of README.txt and HEADER.txt files in a directory listing with:
dir-listing.show-readme = "enable"
dir-listing.show-header = "enable"
Aliasing
mod_alias allows us to specify aliases for directories, effectively importing a completely separate part of the filesystem into our document directory. The
alias.url directive takes a list of alias mappings, as shown here:
server.modules += ( "mod_alias" )
alias.url = (
"/doc" => "/usr/share/doc",
"/mysql" => "/usr/share/doc/mysql-doc"
)
The above configuration will create two aliases, which can be accessed at the addresses
http://your.server.name/doc/ and
http://your.server.name/mysql/, respectively.
If you found this article helpful, consider making a donation to offset the costs of running this server, to one of these addresses: