Nginx (pronounced: EngineX) is a lightweight http server written by Russian, Igor Sysoev. Initially, most of the documentation and discussions were in Rusian but now there’s an English wiki set up for English speaking users. So, through out the day I took a plunge swapping out lighttpd with nginx and watched how it’s going. It’s quite satisfying. I let the process untouched for hours while the site being hit as usual and I can concluded that no memory-leaking type of problem as in lighttpd seem to appear.
The setup was a non-trivial, especially for the PHP/FastCGI thingy but after properly following the example in the wiki and some scattered blog post on the net I got it working. What can I say, nginx configuration syntax is way much verbose compared to lighttpd or apache. It’s programming langguage like syntax make it easy to follow and even vim autoindent work’s perfectly well to auto indent the configuration file. The structure can be logically divided into http, server and location context. Virtual host is just another server context with different server_name directive and location can be nested within any of the main context.
URL rewriting especially for Drupal clean url was a little bit easier. Nginx does provide conditional rewriting so it’s easy to emulate apache rewrite rules come with the Drupal distribution. This forum post on Drupal.org illustrated it well:-
http://drupal.org/node/110224
Unlike Lighttpd, nginx does not automatically spawn FastCGI process for us so we need to invoke PHP as FastCGI externally and then have nginx proxied the request to the process. As suggested by others, I used the spawn-fcgi program from lighttpd to handle the spawning process. Since nginx does not provide any init scripts, I modified the lighttpd init script to handle nginx and PHP FastCGI spawning during system start up and handy daemon start, restart, stop. Just as a note to myself, on Ubuntu (and Debian) init scripts were handled by update-rc.d program: update-rc.d nginx defaults would created proper symlink from the appropriate run level (/etc/rcN.d) to nginx script in /etc/init.d.
Here are some resources on the net that help me to get nginx running on my system:-
http://wiki.codemongers.com/
http://www.nslu2-linux.org/wiki/HowTo/DeployPHPWebAppUsingFastCGI
http://www.google.com.my/searchnginx+php
While the early motivation comes from:-
http://hostingfu.com/article/running-drupal-with-clean-url-on-nginx-or-lighttpd http://forum.slicehost.com/comments.php?DiscussionID=787&page=1#Item_10