Well I recently bought hosting from Dreamhost and had to go through setting it up on the server. I thought it might be useful for others who are following the same path. So here is my $0.02.

How to deploy your application in 8 easy steps:

1. First make sure that your domain has FastCGI enabled. You can do this by the panel, this option is located at Manage Domains -> Edit.

2. Create MySQL databases for your application. This is located at Goodies -> Manage MySQL.

This is probably related to DH taking some time to update my databases, but when I tried to access my database, I received an error:

$ mysql -u username -p -h myserver.mydomain.com mydb
Enter password:
ERROR 1130 (00000): Host 'myhost.dreamhost.com' is not allowed to connect to this MySQL server


This error went away after an hour or so.

3. I'll be continuing as if you are moving an existing rails application that you developed somewhere to the Dreamhost server you have just gotten hold of. There are somethings you need to do before deploying your application. First of all, create a dummy rails project by issuing the command:

$ rails dummyapp -d mysql

The -d flag there tells rails to create the database configuration file stub, database.yml, according to MySQL as the database.

4. Copy your application to the Dreamhost server (I recommend sftp as it is secure). I'll use "myproject" as the name of your own application. Now we'll be copying the dispatch.fcgi that has been created to our own application:

$ cp dummyapp/public/dispatch.fcgi myproject/public/

5. And then we'll be changing the file .htaccess inside the public directory:

$ vim myproject/public/.htaccess

Look for the line

RewriteRule ^(.)$ dispatch.cgi [QSA,L]

and change it so that it uses dispatch.fcgi, so it will be:

RewriteRule ^(.
)$ dispatch.fcgi [QSA,L]

6. Change all permissions if need be:
$ cd myproject
$ chmod 755 public
$ chmod 755 public/dispatch.*


7. Now you can copy the database.yml file from the dummy application to your own application and change the database settings. After that, we do not need the dummyapp anymore, you can safely delete it:

$ rm -rf dummyapp

8. Now the housekeeping stuff.

You should uncomment the RAILS_ENV variable in config/environment.rb so that your application runs in production. If you do not set this your application might be really really slow, or not work at all.

If you have any site specific variables in config/environment.rb, then change it to suit your needs. If you have used Action Mailer to send mails to your users, then you need to configure that as well.

You now have to run "rake db:migrate" to set up the DB and set your applications public directory as your root directory for your domain. That's all folks.


Some DRY Rules That Might Be Useful

If you don't want to create a dummy rails application each time you want to migrate your application to Dreamhost, just copy the needed files to a directory. I copied dispatch.fcgi, .htaccess and database.yml files.


Coupon Code for Dreamhost

If you are ever going to buy anything, don't forget for searching coupon codes on the Internet. You might be amazed how much discount you can get with those. For Dreamhost, the best discount you can get is a 50$ plus you can get other goodies such as free domains or IPs. If you want to get a 50$ discount and 3 lifetime domains for free, use 3DOMAINS4FREE coupon code. I think its the best offer out there. I plan to write a review of using Dreamhost for Rails hosting but probably after some experience with more heavier loads for my application (Turkish only). I think it will be interesting once Dreamhost starts supporting mod_rails also. Shared hosting for rails might just start to be feasible after all.