Project

General

Profile

Actions

LighttpdUnderSuperviseExampleConfiguration » History » Revision 2

« Previous | Revision 2/5 (diff) | Next »
conny, 2006-01-30 14:54


= 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/
/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 "modules.inc"
include "common/common.inc"

  1. default site
    server.bind = "192.168.8.160"
    include "sites/default"
  1. "Multiple bind" hack
    $SERVER["socket"] "132.12.21.20:80" {
    include "sites/foo.com"
    }
    $SERVER["socket"] "132.12.21.21:80" {
    include "sites/foo.co.jp"
    }
    $SERVER["socket"] "132.12.21.22:80" {
    include "sites/foo.se"
    }
    }}}
= File ./root/modules.conf === {{{
server.modules = (
"mod_rewrite",
"mod_alias",
...
}}}

=== File ./root/common/common.inc === {{{
server.pid-file = "./supervise/lighttpd.pid" # ...or maybe ./root/lighttpd.pid is "cleaner"
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/foo.com === {{{
  1. No $HTTP["host"] match required in this example since this site
  2. file was included from within a $SERVER["socket"] stanza...
    server.document-root = /home/foo.com/wwwroot/
    ...
    }}}

Updated by conny over 14 years ago · 2 revisions