A good way to factorise lighttpd configuration files is to use variables and includes. For example, let's say that you have a lot of vhost, each need specific php configuration.
First, create a _php.conf file:
var.phpconf += " -d session.save_path=" + var.statedir + "/sessions" fastcgi.server = ( ".php" =>( "localhost" =>( "bin-path" => "/usr/bin/php-cgi " + var.phpconf, "socket" => var.rundir + "/php.socket" ) ) )
Then in your main configuration file:
var.statedir = "/var/lib/lighttpd/" $HTTP["host"] =~ "a.foo.com" { var.phpconf = " -d magic_quotes_gpc=Off " var.rundir = "/var/run/lighttpd/a.foo.com" include "_php.conf" } $HTTP["host"] =~ "b.foo.com" { var.phpconf = " -d magic_quotes_gpc=On " var.rundir = "/var/run/lighttpd/b.foo.com" include "_php.conf" }
Using that trick, you can do a lot more. For example, here is my configuration file for xf.iksaif.net:
# {{{ variables var.name = "iksaif" var.basedir = "/home/iksaif/public_html" var.logdir = "/var/log/lighttpd/" + var.name var.statedir = "/var/lib/lighttpd/" + var.name var.rundir = "/var/run/lighttpd/" + var.name var.username = "iksaif" var.groupname= "iksaif" var.docroot = var.basedir var.port = 8081 # }}} include "_base.conf" include "_php.conf"