How to Switch WordPress from Apache to Lighttpd

If you are using Ubunutu, there are a couple of packages that you need first.  This command should get you what you need.

sudo apt-get install lighttpd php5-cgi

Now, let’s edit the /etc/lighttpd/lighttpd.conf file.  You need to add mod_fastcgi to your server.modules line.  It should look something like this when you’re done.

server.modules = ( "mod_access", "mod_rewrite", "mod_fastcgi", "mod_accesslog", "mod_redirect" )

Now let’s add the fastcgi.server settings so that it knows what to do with a .php page.

fastcgi.server = (
    ".php" =>
       ( "localhost" =>
              "socket" => "/tmp/php-fastcgi.socket",
              "bin-path" => "/usr/bin/php-cgi"

Now we need to make index.php pages part of the normal start pages.

server.indexfiles = ( "index.html", "index.php" )

Lastly, we simply need to change the document-root to point to our wordpress installation.   It should look something like this.

server.document-root = "/var/www/wordpress"

Now run these few commands to stop Apache, make sure it doesn’t start again, start Lighttpd, and make sure it automatically starts for you.

sudo service stop apache2
sudo service start lighttpd
update-rc.d apache2 remove
update-rc.d lighttpd defaults

That’s it!    Enjoy WordPress running on Lighttpd!