Install RVM, Rails 5, Ruby on a shared DreamHost server

DreamHost doesn’t have much in their KB in the way of RVM/Rails configuration but setting up a current Rails application is not that difficult, but does require some patience.

For this tutorial we will install Rails Keep in mind you will need to install the compatible version of Ruby for the version of Rails you wish to install.

Since we don’t have sudo access on shared, there are  extra steps we need to take to get it it work.

Visit the DreamHost panel and set up a new domain or current one to use Passenger. Visit and click the edit link underneath the Web Hosting column to the right of the domain name. Under the web options heading there is a “Passenger (Ruby/NodeJS/Python apps only):” checkbox that must be checked to enable Passenger support for the domain. Disregard the message stating that RVM is only available on a VPS. You can still use RVM on shared.

Log in via SSH to your site and cd into your root directory.

Install the RVM gpg key:

Install RVM and only RVM. Most tutorials have you install a Ruby binary at the same time but that would result in a permissions error.

Let’s start using RVM by sourcing the RVM script

Now we need to unset GEM_HOME or else gems will get installed in the wrong place.

The next and important step is stop RVM from downloading and installing any lib dependencies as sudo. Most Ruby binaries will work without having to install a dependency.

Now we are ready to install our custom Ruby binaries:

Now that we got ruby installed we can check what our shell is using:

We don’t want to install any gem docs which can add a lot of disk space usage. In our root directory we will add a .gemrc file and add the following to it.

Now we cd into our domains main directory.

We should see a public directory as it was automatically created when passenger was enabled in the panel.

Rather then pollute the RVM global gem namespace we are going to create a special gemset to contain our applications gems. To do this we need to create a .ruby-version file and add the version of Ruby the site will run under and append the name of our gemset with an @ sign.

For this .ruby-version file we will add the ruby version and call our gemset rails5:

Now let’s cd out and back in so RVM can create the wrappers for us. After cd’ing back in we should see the following done automatically the first time:

We can get a list of gemsets by running:

Next install bundler first since it is no longer installed by default.

Now we got our environment set up let’s install rails. In this case we are installing the latest version as of this writing which is

From within our site/app directory lets install rails using the following:

Note the dot which tells rails to install it in the same directory we are in. This command will also run bundler and fetch even more dependencies.

Now we got a problem. How do we tell Passenger to use our RVM Ruby binary? Through an .htaccess file of course. In our main app directory lets create an .htaccess file and add the following:

This is a Passenger directive you can add in an .htaccces file. For more directives check out

Let’s tell Passenger we are in production as well by adding the following on a new line:

A few more steps and we are almost done. Since we are on shared, we have no JS runtime binary installed. Typically this would be node.js but that’s not available on shared. Instead lets modify the Gemfile and uncomment the line with rubyracer in it.

Then run bundle install.

We need to set up a secret key token or else rails will serve an internal server error. We can use a rake command to generate the hash and then add it our .bash_profile as an environment variable as it was meant to be done.

And finally lets add it to our .bash_profile.

Note:Sometimes Rails may not pick up the environment variable. In this case you will want to manually add the hash to the secrets.yml file manually.

Let’s reload Passenger with our new settings from our main app directory:

One more problem. It looks like rails is not working. This is because the default rails smoke test doesn’t work on a Passenger application. We will need to define a simple test controller.

Next, edit the routes.rb in the config directory and add a root route:

Final steps and completion

Lastly, restart Passenger once more using touch.

Now when we reload we got our simple index controller we created previously.

Any time you need to switch to your custom gemset you can use the following:

Have a comment or a question? Feel free to post below.