Deploying rails applications using nginx

Over the weekend I moved some of my rails applications to yet another rails deployment option (See my previous posts on deploying rails with apache, mongrel and mod_proxy_balancer or pound, lighttptd and mongrel).

I replaced apache with nginx, a small fast webserver with good proxying and rewriting capabilities. Nginx is extremely fast, a lot easier to configure than apache and uses much less memory. The process was remarkably painless. The steps I took were:

  • Install Nginx
  • Generate an nginx config file using the nginx_config_generator gem. This gem makes it very easy to configure multiple rails sites.
  • Launch Nginx. Nginx also has some cool features where you can reload the config file or upgrade the nginx binary without restarting it.

First Impressions

I’d intended to migrate to nginx for a while now because I’d heard a lot of good things about it. But I held off migrating sites because of lack of documention and the fact that other deployment options were working well for me.

Of all the deployment options I’ve used so far, this was by far the quickest and easiest to get setup. The nginx_config_generator gem automated most of the configuration and made it very easy to configure multiple vhosts. You create a YAML file describing your vhosts and then generate your nginx config file from this. Here is an example YAML description.

Related links

You can also run php apps under Nginx using fastcgi.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
2 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.