Lighttpd + PHP + MySQL + eAccelerator = WordPress on steroids

30 Apr


Introduction

I recently shifted my blog from Dreamhost to Mosso. Dreamhost was constantly throwing up out of memory errors for my blog and there was no quick way to detect why other than disabling all my plugins and enabling them one by one. That is one route I did not want to take. I was on the lookout for a VPS and was on the verge of settling on Slicehost when Craig suggested I give Mosso a go as it provided a better value for me with their pay as you go bandwidth and secondly it was owned by the same company that owns Slicehost, Rackspace. I finally settled for a 256MB/10GB CloudServer from Mosso.

Initial Setup

I chose Ubuntu Hardy as the OS and was initially at a loss as to how do I go about things. There were lots to do and I was confused as to where to start from.  Craig as always came to my rescuse and pointed out to an excellent guide from nanoTux. This guide details out in precise steps how you can upgrade your OS, set up lighttpd, PHP, MySQL, mail to run WordPress and iptables to firewall my blog.

Initial setup done, I went on to set up DNS records for my domain, my blog and mail which I prefer be handled by Google Apps. This involved setting up A, CNAME and MX records for my domain.


WordPress Issues

WordPress was up and running in no time but I soon figured out that all of my posts returned a 404 since  lighttpd, treats mod_rewrite differently than Apache and does not recognise .htaccess files. I was using a fancy permalinks structure (http://blog.abesh.net/yyyy/mm/dd/post-name) which  Apache accomplishes with  mod_rewrite and .htaccess files.

Skimming the internet I found Emil Haukeland‘s  blog which showed me the way out:

Literal Thoughts had a solution for WordPress MU as well:

I followed these instructions and my posts came back up.

The next issue that I found out was with WP Super Cache, a caching plugin for my blog. It needs Apache with  mod_rewrite to work and I would need to hack it in order to make it work with lighttpdGiovanni Intini has a two part blog on how to achieve this with mod_magnet and Lua on lighttpd :

As well as Asterios Katsifodimos who has a detailed guide on his :

Everything done and WP Super Cache was working again.


Installing eAccelerator

From the eAccelerator website :

eAccelerator is a free open-source PHP accelerator, optimizer, and dynamic content cache. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.

Their Wiki is extremely good and has clear instructions on how to install it. I would recommend going through it step by step to easily enable eAccelerator for your blog.


WordPress Performance Optimization

There are a lot of blogs on the internet for  performance optimization, but I found this one from Elliott C. Back to be the best of the lot :

And that’s it. You’ll have a blazing fast WordPress installation to serve your blog.