WordPress with lighttpd

A few days ago I switched the webserver for schmalenegger.com from Apache2 to lighttpd. Here’s a short guide what needs to be done to get lighttpd running with WordPress:

As I use Debian Etch, I decided to give to lighty packet from the Debian repositories a shot.


apt-get install lighttpd php5-cgi

After installation the webserver needs to be configured. This is done in the file /etc/lighttpd/lighttpd.conf.


#Load the FastCGI-Modul
server.modules = (
"mod_fastcgi",
)

#Configure PHP
fastcgi.server = ( ".php" =>
(
( "bin-path" => "/usr/bin/php5-cgi",
"socket" => "/tmp/php.socket",
"min-procs" => 1,
"max-procs" => 3,
"max-load-per-proc" => 3,
"idle-timeout" => 20 )
)
)

That should be sufficient for running WordPress. Just put your WordPress files under the configured server.document-root from lighttpd.conf and point your webbrowser to your domain.

But what about permalinks?

lighttpd has something called conditions. You can also use them for separating different sites from each other on the same server (Virtual-Hosts in Apache), but also Rewrite Rules can be configured there. So first of all make sure, that the Rewrite-module gets loaded from lighty and add mod_rewrite to the list of modules:


server.modules = (
"mod_rewrite",
)

Then configure some conditions (replace the domains with your own)


# Conditions for different sites
$HTTP["host"] =~ "^(www.)?(schmalenegger.com)$" {
server.document-root = "/www/schmalenegger.com/"
accesslog.filename = "/logs/schmalenegger.com-access.log"
url.rewrite-once = (
"^/(wp-.*)$" => "$1",
".*\.(txt|php|xml|js|ico|gif|jpg|png|css|swf)?.*$" => "$0",
"^([^?]*)?(.*)$" => "/index.php$2"
)
}