26 Jul
Posted by suresk as Software Development, Websites, Rails
I think I’ve gotten the art of deploying a rails app on a DreamHost down, and a few friends have asked for a quick tutorial, so here it is. Once you learn how to do it, you can get a new app up and running in 5 minutes or less.
This assumes you know how to use Subversion and want to use it. It also assumes (of course) that you are using DreamHost. If you are using another host, some of the steps may still be helpful. If you are interested in trying out DreamHost, read our review here.
1) Make sure your current domain has FastCGI support (you can view/change this on the manage domain -> edit screen).
2) Setup a subdomain for your site. I use something like resources.mysite.com, then setup a mySQL database and SVN repository using the subdomain you just created. This takes a few minutes to do.
3) If you haven’t started your Rails project yet, checkout the project and then run rails to build the project in the svn managed directory. If you are trying to deploy an existing Rails app, you can use svn import to import your files into the repository.
4) Update the production section of your database.yml file to point to the database you just setup. You’ll need to add another attribute called ‘host’ that points to the subdomain you just setup, ie - host: resources.yoursite.com.
5) Check everything in.
6) On the server, check the project out into a subdirectory of the site you just setup.
7) You’ll want to go into that directory and run your migration scripts. First, you’ll need to set the RAILS_ENV variable (ie, export RAILS_ENV=production).
8) In config/environment.rb, there is a line that says “ENV[’RAILS_ENV’] ||= ‘production’” - remove the # to uncomment the line.
9) In public/.htaccess, on or around line 32, it says “RewriteRule ^(.*)$ dispatch.cgi [QSA, L]” - change the dispatch.cgi to be dispatch.fcgi.
10) Now you need to get the dispatch.fcgi file. The easiest way to do this is to go to a different directory and create a new rails app (ie, rails temp). There will be a dispatch.fcgi in the public directory - copy this over to your real project’s public directory. I did this once and then copied the file to a common place so I wouldn’t have to create a new rails app for each project.
11) In your DreamHost control panel, edit the domain this application is running on. There is a setting called “Specify your web directory:” that probably currently has “yoursite.com” in the text box. Change this to “yoursite.com/your_app_directory/public”.
Your app should be up and running now - try it out :)
One Response
jason
August 6th, 2007 at 10:32 pm
1hey- just a note of thanks. I have read through several of these ‘deploy to dreamhost’ type articles, and none of them worked. This was quick and simple, and worked first try!
thanks,
jason
RSS feed for comments on this post · TrackBack URI
Leave a reply