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

As I showed in a previous post installing RVM and Rails 5 on a shared server isn’t that difficult. The process on a VPS is for the most part almost the same save a few steps. Again since there is no sudo on a VPS some changes must be made.

First step is to 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. 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. Make sure that the user is set up on a VPS and not shared. For now, do not check the RVM checkbox. We will get to that later once we have installed RVM.

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:

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 have to tell Passenger to use our RVM Ruby binary. On a VPS this is done via the panel (but can be done via an .htaccess if you want to verify the install right away). It is the same as adding the PassengerRuby directive via an .htaccess file but the panel adds it to the virtual host file for even better performance.

Visit and click the edit link to the right of the domain underneath the web hosting column. Scroll the RVM check box and check it to enable the option. We have to point Passenger to our RVM wrapper for our Ruby/gemset combo. In the field that appears next to the check box I added the following for my installation.

Save the settings and wait about 10 minutes for the changes to take effect.

There are more passenger directives you can use in the apps root directory if you want to add some extra settings. For more directives check out

You can tell Passenger to run the app in production as well by adding the following line to an .htaccess file located in the apps root directory:

A few more steps and we are almost done. Since we are on a DreamHost VPS, we already have a JS runtime in the form of node.js. So no extra JS runtime needs to be installed.

Secret Key

We need to set up our secret key token in our secrets.yml file inside of the config directory 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 route 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

Restart Passenger once more using touch.

Now when we reload Rails will server our simple index controller.

Page showing default index controller page
Rails successfully installed on a shared server

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.