Installing Ruby on Rails on DreamHost

After initially deciding to try TextDrive I eventually opted for DreamHost because it looks like they are going to offer better long term stability. But DreamHost doesn’t support Rails natively, and aren’t planning to until it gets into Debian’s stable release, so sometime in 2010. But it’s a pretty flexible host so you can run your own software. I came across this guide for installing Rails on DreamHost:

http://www.numberporn.com/archives/000118.php

Unfortunately, it already appears to be out of date, and the last Apache configuration doesn’t work with the current version of Rails. But that’s just a minor blip because each request reloaded the entire Rails framework, so I doubt it would have been usable.

I decided to give up trying to get it to run inside Apache and just use the WEBrick server that comes bundled with Rails. First startup the server (from the root of your Rails application):

nohup script/server -e production &> log/WEBrick.log &

At this point you should exit your ssh session then relogin because if the ssh session times out it’ll take WEBrick with it, but exiting means nohup will keep it alive.

The next step is to get Apache to forward to WEBrick. In the ‘.htaccess’ file in your web directory, enter:

RewriteEngine On
RewriteCond   %{SERVER_PORT}  ^80$
RewriteRule ^(.*)$ http://www.yourhomename.com:WEBRICK_PORT/$1 [L]

Replacing yourhomename and WEBRICK_PORT with the actual values. This makes Apache redirect all requests to WEBrick. The only annoying thing is it displays the port number in the rewritten URL. This is fine for toy applications, but not good enough for production applications. In theory replacing [L] with [P] is supposed to mask this by making Apache act as a proxy, but it returns a 404 instead. Everything I learnt about Apache configuration I learnt in the past hour, so there’s a good chance I’m doing something wrong.

But anyway that gets your Rails app running on your DreamHost account, which is a definite step forward.

Spread the word: Technorati related  |  Technorati related  |  del.icio.us bookmark it!  |  submit Installing Ruby on Rails on DreamHost digg.com digg it!  |  reddit reddit!

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>