Moving from Apache to Cherokee Web Server
05 Apr 2011I recently decided to move a website of mine from Apache to Cherokee. Why? Because Cherokee is fast and Google likes fast sites. Apparently, Cherokee is the fastest web server in town. I first read about Cherokee in Linux Format magazine and decided to give it a shot with my AdFlickr site which I have running on a Linode instance (Ubuntu 10.04 by the way).
Installing Cherokee on Ubuntu 10.04
Fortunately, it is really easy to install Cherokee on Ubuntu 10.04 since version 0.99.39 is available in the software repositories. Here is basically what I run in my server.bash file to install Cherokee, PHP and MySql:
Tunnelling into the Cherokee Admin
Cherokee includes a web admin interface for configuring the server. To get that running you need to start it up on your server and then use SSH tunnelling to view in a local browser. So on your server run the following to start the Cherokee Admin deamon:
Then on your local machine, setup the SSH tunnel as follows:
Now, navigate to http://localhost:9090 and log in using the username and password shown in the output on your server console. You should be greeted with the Cherokee Admin home screen!
Configuration of Cherokee is a breeze with the use of Wizards. Just navigate to your Virtual Server Behaviour tab, click on wizards button and select the appropriate category. For PHP select Languages then Run Wizard next to PHP.
Specific issues when moving from Apache
I had two issues, one was not having installed php5-cgi which I simply added to my apt-get install list. The second issue was related to url rewriting (e.g. all the rewrite rules I had in my .htaccess file). I found that the syntax did not exactly copy accross to Cherokee. I also found that in Web Admin interface did not preserve the ordering of the rules, so I decided to edit the cherokee.conf file directly.
Here are a few examples of the rewrite rule in the Apache .htaccess file compared with the Cherokee .conf file (I have removed the vserver path from the Cherokee examples removed for clarity):
Production Deployment
Once I had Cherokee running perfectly in my development environment (aka my laptop), I proceeded to deploy to my production environment (aka Linode). Now, I could clone my Linode instance and deploy there and then update my DNS, but I was feeling brave and I was sure the deployment would go smoothly which it did. All I had to do was:
- Run server.bash to install cherokee
- Run a deply.bash script which (amongst other things) copies the cherokee.conf file to /etc/cherokee/
- Stop Apache running /etc/intit.d/apache stop
- Start Cherokee /etc/init.d/cherokee start
The site is now up and running on Cherokee. I hope you can join the Cherokee crowd one day too!