HOWTO: Set up a Rails 3.2.11 (ruby 1.9.3) app on a dreamhost shared account

I recently took advantage of a sweet deal at Dreamhost and signed up for a year of their "Shared Hosting". Being a Railsist (??) I wanted a temporary domain / server where I could throw up my random Rails / Rack projects.  Its definitely doable, but there is a tint of hacking involved.

First off, go into your panel and click "Manage Domains" section and edit the domain you want to run rails on.  Scroll down and check the Passenger checkbox since we'll be using their pre-installed passenger setup to serve up our applications.  Since I will be using Capistrano to deploy my applications I also changed the 'Web directory' to /home/username/domain.name/current/public.  This might not be necessary for you depending on your setup.

Next up we're going to want to enable shell access so you can deploy your application and install some other required software.  Go to 'Manager Users' section of the panel and click 'edit' on the user you want to allow ssh access to.  Change the 'account type' to Shell account instead of the default FTP account.

Now create a mysql database (unless you plan on using sqlite).  Click into "Mysql Database" and add a new one.  Note that you will not be able to connect to the database via localhost or the socket file, so you will have to add whatever hostname you chose to your production database.yml file.

You'll see a warning that it might take 5-10 minutes for the settings to change, one that happens then you can proceed.

By default, Dreamhost only has Ruby 1.8.7 installed :(  Go ahead and ssh into your shell and we'll start by installing RVM and the latest ruby.  Run the command \curl -L https://get.rvm.io | bash -s stable --ruby to install both in one shot.  I usually do a rvm use default 1.9.3 just be sure I'll be using the correct ruby version, but this might not be necessary.

When thats finished go ahead and insall the Rails, mysql and therubyracer gems gem install rails mysql2 therubyracer

We're also going to want to install node.js for our javascipt runtime and compilation.  In your home directory, create a downloads folder mkdir downloads; cd downloads .    We're also going to need a ~/usr/local/bin dir to store the node binaries mkdir -p ~/usr/local/bin. Grab the latest node.js source from github git clone git://github.com/ry/node.git; cd node.  Make that shit ./configure --prefix=~/usr/local; make; make install and add our the bin directory we created to the environment path by adding export PATH=$PATH:/home/USERNAME/usr/local/bin to both .bashrc and .bash_profile replacing USERNAME with your account username.  Now close your connection and re-connect to check if node installed correctly with node -v .

You now have an up to date Rails server with the latest Ruby and Node versions installed.