Nginx + PHP-FPM, long recipe for a tuneup

My new blog engine looked and felt all fine except for being an extreme resource hog. I have barely 1 GB of RAM on my virtual server from HostEurope, which is more than enough if you just want to run one under-subscribed site. But I also happen to run Spring’s new TC server for my own projects (one of which I should be unveiling by the end of this month). So I decided to explore on how to make the whole blog lean. The process was not easy. First I am on Ubuntu LTS so only the most stable software is available for tunning. So this means I had to compile lots of things by hand. Second there is no complete instruction set for doing so on Hardy (which will be ousted soon by new LTS version). But some instructions are still worth mentioning. I might be tempted to write my own complete DIY nginx,wordpress on php-fpm entry after the new LTS is released.

I decided to go with Nginx and PHP-FPM solution for running Wordpress (and then later I can also put in Passenger for my RoR applications). Nginx is very lean Webserver which is changing the whole landscape of LAMP to LEMP (it’s pronounced as engine-x). I had been using it previously as well but it’s a moving target and has progressed a lot since I last dove into configuration files. There are various resources on the internet addressing this kind of migration but none of them complete. In order to handle redirects as 301 and not as 302 I used this plugin, and this post was extremely helpful in getting the permalinks working properly.

I also got to optimize my MySQL for memory use but I think there is still room for improvement.

Initial tests with a blank TC server and a running blog on stock Apache and Mysql would reat away all the available RAM. Now I have been able to shave off about 100 MB (which is not bad). I will see if running standard Tomcat works as it uses less memory than TCServer (from the looks of it)

Posted Sunday, March 14th, 2010 under Meta, Technology.

Leave a Reply