Entries tagged with “Phusion Passenger”

Deploying Rails on Dreamhost with Phusion Passenger

Deploying Ruby on Rails has always been a pain, even with tools like Mongrel and Capistrano. On shared hosting, it’s nearly impossible. A little while ago, I noticed a project called Phusion Passenger (aka mod_rails), which sought to make deploying as easy as uploading your application to your webhost. A few days ago, Dreamhost (my host) announced on their blog that Phusion Passenger was available on their servers. Naturally, I took some time to play around with it, and so far I’ve been extremely impressed. I threw together a quick app using Viddler.rb and deployed it to Dreamhost (you can see it here). Here’s a quick guide on how to deploy to Dreamhost yourself using mod_rails.

Getting set up

The first thing to do is to set up your domain or subdomain to use Passenger. Just go to the Manage Domains page on the DH web panel, and either create a new domain or edit an existing one. Check the “Ruby on Rails Passenger (mod_rails)?” checkbox and set the web directory to where the public directory of your app will be. Below is a screenshot of my settings for viddler.fidgeting.net.

mod_rails settings

Next, you need to create your database, so just go into the Manage MySQL section of the panel. Create your database, which should be named as a production database. In my case, it was viddler_production. Then, make sure to change your database.yml to reflect the database you just created.

Uploading and running your application

Before uploading, make sure the first line of your public/dispatch.fcgi has the correct path to ruby on Dreamhost (which is /usr/bin/ruby). Then all you need to do is upload the files to Dreamhost and go to the domain. That’s it—your app is now completely functional. Amazing, huh?

If you need to first run migrations, you can do that from SSH with this command:

RAILS_ENV=production rake db:migrate

If you need to restart your application (anytime you change any files), just run the following command via SSH:

touch tmp/restart.txt

Getting Gems to work on Dreamhost

Since Dreamhost is a shared host, you can’t directly install gems on the server. Dreamhost’s wiki has a lot of information on different ways to get gems working, but they are all fairly involved, and I couldn’t get any of them to work. The way I did it was by unpacking the gems into vendor/gems by using the “gem unpack” command:

gem unpack <GEM NAME>

I’m sure there are better ways to do it, but this method worked perfectly for me.

Overall Impressions

Like I said at the beginning, I’m very impressed with Passenger, and so far I haven’t noticed any issues. The total time for me to deploy was about 20 minutes: way faster than with Mongrel or FastCGI. It’s definitely awesome to see a host as large as Dreamhost using this, and hopefully soon more will follow suit.

Posted on May 17, 2008 30 Comments
Tagged with: , , , , , ,