Lakshan Perera

Passenger - Holy Grail for Ruby Deployment

Popular notion about developing web apps with Ruby on Rails (or other Ruby frameworks) was "You can write a web app in 15 minutes, but it will take 15 days to deploy it correctly". Especially if you are coming from the world of PHP, where you have to just write the app and upload it, this might have been utterly confusing. Having to juggle with Apache/Nginx, Mongrel clusters, or FastCGI, just to deploy a simple web app would surely have sounded a nightmare.  You must have wondered countless number of times why doesn't it just work as in PHP ??

Well, finally you're prayers have been answered! Enter Phusion Passenger( a.k.a mod_rails or mod_rack), a module for Apache web servers, which will make deploying ruby app just a breeze. Yeah, like in good old PHP now you can now just upload your app and you're live! voila!

Thanks to Passenger, now you can use the same Apache web server where you hosted  your legacy PHP apps, to deploy your Ruby apps. Also, if you cannot afford to pay for a VPS, you can even use a cheap Shared host such as Dreamhost (which already supports Passenger). If it was the hassle of hosting the apps, which prevented you from developing in Ruby apps, it should not be a problem anymore.

So how I get up and running?

Installing Passenger is simple and the process is unbelievably user-friendly. All you have to run is just two commands in your terminal. (I assume you have installed Apache 2, Ruby and Ruby gems)
sudo gem install passenger

and then run,

passenger-install-apache2-module
Passenger installation screen

Then you will be presented with the following guided installation process. Just do as it say and you're done!

If you are using Dreamhost, Passenger comes built-in with the hosting package. You have to enable it for the domain you wish to host your app, through the Dreamhost control panel.

Once you've installed (or enabled) Passenger, you could just upload the files using your favorite FTP program (or using SFTP/SSH)

When you make updates, you will need to restart the application to reflect the changes. It's also not that difficult all you have to do is to create a blank file called 'restart.txt' on your application's tmp/ directory. You could do this by running following command in the terminal.

touch /webapps/myapp/tmp/restart.txt

If you are used to automated deployment using Capistrano, deploying apps can be even simpler. Here is a sample recipe on how to do that.

You need further information about Passenger,  the offical user guide and following collection of resources can be helpful.

Kudos

Few months ago there were lot of dispute regarding complexity of Ruby deployment, then DHH (creator of Rails) openly invited to someone to tackle the challenge rather than just complain. In this context, Phusion, a small company in Dutch came up with Passenger. It's a truly a great effort which made our lives easy. Kudos for the fine folks over at Phusion, you guys really rock !