Using WordPress and W3 Total Cache with Lighttpd

If you have a small VPS (1 CPU, 1 GB RAM) you may find usufull to drop apache for lighttpd.

Lighttpd uses less memory and CPU but unlucky does not have support for apache’s .htaccess config file.

To have WordPress running smothly under lighttpd you have to implement some config yourself using its mod_rewrite.

This is part of the config i use to implement correct SEO permalinks and also i had a little W3 Total Cache support that can be used togheter with X-Cache.

Differently from other examples that you can find on the net, i used url.rewrite-if-not-file to redirect to wordpress index.php only when a URL does not match an existing files.

I also added a little configuration to allow the browser to cache static resources by url path or by file extension.

url.rewrite-if-not-file = (
	# w3tc support
	"^/wp-content/cache/minify/(.+\.(css|js))$" => "/wp-content/plugins/w3-total-cache/pub/minify.php?file=$1",
	# wordpress
	"^/(wp-.+).*/?" => "$0",
	"^/keyword/([A-Za-z_0-9\-]+)/?$" => "/index.php?keyword=$1",
	# permalinks and 404 not found
	"^/.*?(\?.*)?$" => "/index.php$1"
)

# allow caching of static resources
expire.url = (
		"^(wp-includes|wp-content)/(.*)" => "access 7 days",
		"^(.*).(js|css|png|jpg|jpeg|gif|ico|mp3|flv)" => "access 7 days",
)

Using WordPress and W3 Total Cache with Lighttpd, 5.0 out of 5 based on 2 ratings
GD Star Rating
loading...