By Myles Eftos

Smooth your deployment with Passenger

By Myles Eftos

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:

  1. Install Apache (check with your vendor for instructions)
  2. Run gem install passenger
  3. Run passenger-install-apache2-module

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.

    ServerName test.localdomain
    DocumentRoot /home/sites/test

If you are using passenger for development, make sure your apache2.conf file has the line RailsEnv development.

  • JdL

    Hey Myles — any chance you know anything about when they might have a version for Windows available?

  • phpimpact

    Although mentioning PHP or Python is a good publicity for Ruby, I think mod_rails should not be compared to mod_php. Harry Fuecks explained this a couple of years ago, but there’s still some confusion about it.

    “PHP is optimized to that environment. By contrast Perl, Python and Ruby are general purpose languages and optimized to different requirements. The web is just another platform they support, compared to PHP where the web is the primary platform.”

    Learn more about the execution model. With a good execution model, your can develop large-scale applications.

  • madpilot

    jdl: Not sure – All I’ve heard is “it’s coming”.

    php_impact: I disagree. Ignore the fact that PHP is a language and Rails is a framework for a moment (remember that mod_rails only works with Rails, not general Ruby making it a fair comparison), how is PHP any more web-centric than Rails?

    Rails has been designed to make building database-driven web applications, and now with mod_rails it is as easy to deploy as PHP is. I think this is very significant step towards Rails becoming a mature platform.

  • phpimpact

    Yes, I completely agree, it is a very significant step towards becoming a more mature platform, no doubts about that.

    I was referring to this article.

  • madpilot

    phpimpact: That is exactly what mod_rails brings to rails :)

    Admittedly, the model modrails uses is probably closer to the ASP.NET Application Pool model – there is a live rails process always running.

  • Hongli Lai (Phusion; Passenger/mod_rails developer)

    (Note: I’m from Phusion => I’m one of the Passenger/mod_rails developers)

    Hi Myles. It’s good to know that we’ve caught Sitepoint’s attention. Passenger was written with shared hosts in mind. I’d like to let you know that we’re going to publish a series of articles about memory usage and startup time in Rails, and what Passenger does about that in order to make Rails more suitable for shared hosts. We think that you might be interested that, so please keep an eye on our blog for updates. :)

    @madpilot, @jdl:
    It’s not “it’s coming”. Actually, it won’t be “it’s coming” for a long time. We have no plans to support Windows for the forseeable future. This is not because we’re ***holes who want to screw over Windows users, but because Windows lacks the infrastructure and capabilities to implement Passenger efficiently.

Get the latest in Front-end, once a week, for free.