Smooth your deployment with Passenger
I alluded to the release of Phusion’s Passenger (AKA mod_rails) – an Apache module that can run multiple Rails sites, just as PHP does. The significance of this is pretty huge. Up until now, running rails has required running Mongrel behind an Apache proxy or using FastCGI (or preferably fcgid).
Although Mongrel did a sterling job, I have never been a big fan of having two points of failure – problems with either Apache or Mongrel would render your site unreachable. Not only that, adding capacity to your system required adding a number of mongrel instances, each with it’s own port and each with it’s own memory overhead, which can get very messy for shared hosting providers.
Passenger will allow hosting providers to install one Apache module, requiring the client to simply upload their application – no permission issues, or troublesome configurations files. However, it is also very useful for a developer – instead of having to run
script/server when testing your application, you can install a local version of Apache, setup a few virtual hosts, and have instant access to your test sites.
Currently, Passenger only runs on *NIX type environments, eg Linux and OSX. The Phusion team have worked pretty hard to make the installation as simple as possible. Here are the basic steps:
- Install Apache (check with your vendor for instructions)
gem install passenger
Passenger should now ask you a few questions, which if you answer correctly, should complete the installation.
Restart Apache and create a virtual host file, which points at your Rails application, and you are away! The following virtual host file will tell Apache to respond to the url http://test.localdomain with the Rails application in /home/sites/test.
<VirtualHost 127.0.0.1:80> ServerName test.localdomain DocumentRoot /home/sites/test </VirtualHost>
If you are using passenger for development, make sure your apache2.conf file has the line