I recently needed to set up a new server to act primarily as a web server. With Rackspace, this has a very easy beginning: choose the Gentoo image and create the server. Typically I run emerge –sync, emerge -avuDN @world (wait a while), revdep-rebuild, emerge –depclean -a, and python-updater in that order to make sure I have things up-to-date. There are some other clean up items that also need to be done since at least at this time the Rackspace image needs a bit of updating but that is minor. While I waited for the initial emerge @world I got busy and configured the server security and other basic services the way I like.
I wanted to use Apache 2.4 since it is suppose to be better so I did a lot of research on installing and configuring it. With a fresh server I had a fresh start. I have used php-fpm for a while now in my new servers and I thought based on some articles on the Net it would be somewhat trivial to get Apache 2.4 to work with php-fpm especially with the new default event mpm. After a day of banging my head against that wall I gave up, uninstalled 2.4 and installed Apache 2.2 and quickly had it running with three different web sites.
But I wasn’t happy. As I researched the issues I was having with Apache 2.4 I kept seeing things about Nginx (pronounced engine x). I know all the positives that Nginx has especially its performance benefits. It has a lot of good buzz. I have been intrigued by it for many years and seem to install it every so often but I never pull the trigger to switch.
I am comfortable with Apache but more importantly, every time I try Nginx I run into major problems. The biggest warning that everyone seemed to say that Nginx was good for single host web sites but not for shared hosting. Since I rarely set up a server that only serves a single web site Nginx seemed to be a no go for me. I also have never liked the lack of an equivalent to the .htaccess file. It always seems that this leads to incompatibility with standard CMS and web frameworks.
But, I decided to do some research to see if Nginx would work. After setting the USE flags I did a quick emerge -av nginx to compile and install it. After doing the basic configuration to have Nginx work with php-fpm I checked the localhost install and was pleasantly surprised that everything worked. After setting up the virtual host files for the three web sites I reloaded Nginx and was rather surprised again that all three sites, a WordPress site, a ZenCart site and a Joomla site worked. More importantly, I started to grok Nginx configuration and felt like there are some major behind the scenes advantages to Nginx. I have actively used the WordPress site for several days without problems.
I still have some other tests to run but so far Nginx has proved to be a good replacement for Apache where I previously found it lacking. I haven’t tested its performance against the Apache server, I will, but I have already noticed that it doesn’t take as much server resources as Apache did. And the major complaint about shared hosting seems to be a non-issue for now. I may still need to switch back if I run into an issues that Apache can solve but Nginx can’t but for now, I am a reluctant for now convert.
Follow up: A Year Later
Well, I ended up having enough little issues that other than one site, Nginx has not really taken over for me. In fact, we had one site that kept having minor issues. Just for testing purposes, I switched it from Nginx to Apache and all the problems went away. I believe it had to do with the rewriting needs of the site. Although we noticed a minor performance hit, we never switched it back to Nginx, don’t fix what isn’t broke eh?
- Gentoo Linux, Why?
- Another Isn’t She Cute