Monday, December 3, 2007

Rails on Dreamhost

Setting up Rails in Dreamhost is a bit tricky. Dreamhost has a wiki on how to do it but as of today, it doesn't work quite right.

I just installed on and it worked fine so here's how I did it:

1) If you haven't yet, create the user account through their control panel with FCGI enabled.
2) Log on to the user account that you created via shell.
3) type "rails yourappname"
4) type "rm useraccount.dreamhosters.com" since we'll replace it with a symbolic link.
5) type "ln -s yourappname/public/ useraccount.dreamhosters.com"
6) type "cd yourappname"
7) edit public/.htaccess (make sure what you edited isn't the commented line):
RewriteRule ^(.*)$ dispatch.cgi [QSA,L] to RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
8) After require 'fcgi_handler', change the rest of dispatch.fcgi to read:
class RailsFCGIHandler
private
def frao_handler(signal)
dispatcher_log :info, "asked to terminate immediately"
dispatcher_log :info, "frao handler working its magic!"
restart_handler(signal)
end
alias_method :exit_now_handler, :frao_handler
end

RailsFCGIHandler.process!
9) edit your config/environment.rb and uncomment the line:
ENV['RAILS_ENV'] ||= 'production'

10) Your Rails app should be working fine now. You'll need to edit the database.yml and stuff to make sure that you can connect to the database of course.

Goodluck!

No comments: