1
Posted by alex on Jan 20th, 2011

I was not able to find a simple way to use wp-super-cache with lighttpd, some were using 100 lines lua script and the others were unreliable at best. After an hour of fiddling, I came with the following configuration.

What it does:

  • It serves a cache file only if the user is not logged in.
  • If no cache exists, the 404 handler loads index.php which will either find the correct page (and generate missing cache), or return a true 404.
  • It does not mess with /wp-admin or /wp-content or any file that exists outside the cache.

In green are the values that you will have to edit

$HTTP["host"] == "blog.alexou.net" {
	server.document-root = "/var/www/wordpress"
	server.error-handler-404 = "index.php"
	$HTTP["cookie"] !~ "^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" {
		url.rewrite-once = ( "^/wp-admin(.*)(?:\?(.*))?$" => "wp-admin$1?$2" )
		url.rewrite-if-not-file = ("^/([^\?]*)$" => "wp-content/cache/supercache/blog.alexou.net/$1" )
	}
}

Note: You need lighttpd >= 1.4.24 because earlier versions do not have rewrite-if-not-file.

1 comment
Commentaires
avatar
Jevermeister
Hi,

i just tried your configuration and kept getting error 500 after a while. Had the same problem with rewrite.lua and by using the php cache variant. Do you got a clue why this happens?

i'm hosting multiple websites on my server and only www.jevermeister.de stopped working after ~5 minutes with an error 500 until i restarted lighttpd.

Regards,

Jan aka Jevermeister
Connectez-vous ou postez en tant qu'invité:
Your Name Your Email


Vérification: 0265
Go to Top