Peter's Blog

Redefining the Impossible

Nginx


Nginx? Think 'Engine X' (NOT en-jinx like I keep thinking). It's a web server, one that is very popular in Russia (the first country into space). It can be thought of as a modern, lean mean web server that does away with the bloat of Apache. It is very good for use in VPS's where memory could be at a premium.

I tried it on my new Slicehost VPS and it was up and running in about ten minutes, proxying to my mongrel cluster (which didn't need rebooting when I swapped web servers) like a good'un. The configuration files are very clear and the ubuntu installation is similar to the apache configuration that I am familiar with. It is possible to add a new virtual site in a minute or two, adding a configuration file that is as simple as:

server {
    listen          80;
    server_name     www.domain1.com;
    access_log      logs/domain1.access.log main;

    location / {
        index index.html;
        root  /var/www/domain1.com/htdocs;
    }
}

This is pretty much all you want to state: the name of the site, a path within the site and where it maps to on the file system. For the mongrel proxying I used a recipe I found: the nginx wiki has many such recipes. It reminds me of cherrypy and how most of the recipes on it's wiki were incomplete or broken, something that ultimately contributed to me abandoning turbogears, django and python for ruby on rails.

I was encouraged to see that Nginx can support drupal quite easily as it's url rewriting rules are capable of pleasing drupal's 'clean urls' mode. Lighttpd can support drupal if you do some php hacking.

Nginx doesn't directly support cgi (as a security feature!?!) but it can support fcgi by talking to a fcgi process via a proxy. I haven't tried this yet but it would be the route I would take to support php (if I wanted drupal on my nice box). I would also dearly like phpmyadmin to be available (hidden from the outside world, only accessable through an ssh tunnel of course). My one hope is that such a fcgi php process can support more than one application (can never be sure with these things).

I read more about lighttpd and found mumblings of bugginess in proxying mongrel clusters and some security concerns. I read nothing but good about Nginx.

n.b. unlike lighttpd

/etc/init.d/nginx restart

actually restarted the server (not having to expressly kill the old processes).


Filed under: apache lighttpd nginx

Comments are Closed