Lighttpd configuration layout

The application configuration files can be placed below the service directory as well in a djbdns-similar way. Thanks to the include-directives of Lighttpd, your configuration can be split up into smaller parts, put into subdirectories, and maybe even shared between multiple lighttpd service instances.

Similarly, by combining the environment variable substitution directives ("env.*") with the envdir program your configuration could be modularized almost ad infinitum.

The term "service instance" is used to refer to the fact that it works perfectly well to have multiple instances of lighttpd running on your server, each on different ip/ports with different privileges.

Example 1

Continuing on the example used in LighttpdUnderSupervise:

/srv/lighttpd-main/root/         # root directory of the lighttpd configuration
/srv/lighttpd-main/root/common/ -> /etc/lighttpd/common/ # symlink pointing to a shared directory
/srv/lighttpd-main/root/htdocs/  # default website root
/srv/lighttpd-main/root/sites/   # vhost configuration files

File ./run

#! /bin/sh

exec 2>&1
exec softlimit -m 700000000 /usr/sbin/lighttpd -D -f ./root/lighttpd.conf

File ./root/lighttpd.conf

Because we used the -f parameter, the base for other included files will be /srv/lighttpd-main/root/.

include "" 
include "common/" 

# default site
server.bind       = "" 
include "sites/default" 

# "Multiple bind" hack
$SERVER["socket"] == "" {
        include "sites/" 
$SERVER["socket"] == "" {
        include "sites/" 
$SERVER["socket"] == "" {
        include "sites/" 

File ./root/modules.conf

server.modules = (

File ./root/common/

# is not needed 
server.username  = "www-data" 
#server.max-keep-alive-idle = 30

File ./root/sites/default

server.document-root = "./root/htdocs/" # default website root
status.status-url = "/server-status" 

File ./root/sites/

# No $HTTP["host"] match required in this example since this site 
# file was included from within a $SERVER["socket"] stanza...
server.document-root = /home/