Aller au contenu | Aller au menu | Aller à la recherche

/var/log/iksaif

vendredi, janvier 22 2010

lighttpd configuration: variables and includes

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"

iksaif.net migration to lighttp

This week I migrated iksaif.net (and zordania.com, finestown.com, etc...) from apache to lighttpd !

It used to be like described in my previous post: http://xf.iksaif.net/blog/index.php?post/2009/05/08/Securing-a-shared-Web-Server

Now, the architecture is more like that:

lighttpd-misc --- git
                    \- redmine
                    \- lighttpd-iksaif - xf.iksaif.net
                    \- apache          - svn
                                           \- trac
                                           \- finestown
                   \- lighttpd-zordania
                   \- lighttpd-zorddev
                   \- lighttpd-uffs    - blog
                                           \- git
                                           \- redmine

Is not as performant, but it's a lot more flexible. I had to keep apache for some svn repository, because there is no dav-svn module for lighttpd.

I learned a lot, so I'll post some lighttpd configuration examples that could help you one day.