How to install rvm & ruby on shared hosting

By Faramarz Salehpour

Let's assume that you have shell access to your shared hosting service.

Install rvm

rvm is a ruby version management solution which makes it possible to install different versions of ruby on a computer and switch between them on the fly without causing too much trouble.

$ \curl -sSL https://get.rvm.io ' bash -s stable

You might get a few warnings, it's better if you address those before proceeding. Now if everything has gone as planned, rvm should have added itself to your path somewhere in .bash_profile or .bashrc or even in a separate .profile file which should be sourced in your .bash_profile (by adding source ~/.profile to your .bash_profile). Run the script to update the path (or simply logout and login again).

$ source ~/.bash_profile

Install ruby

The easy way -- Installing a binary

If you prefer to use ready-made binaries from rvm.io, you can head to the list of binaries and choose the proper binary which matches to your host's OS version and machine arch (e.g. Centos 5.6 x86_64). Then mount the remote binary using rvm:

$ rvm mount -r http://rvm.io/binaries/centos/5/x86_64/ruby-1.9.3-p547.tar.bz2

Now you can tell rvm to use this version:

$ rvm use 1.9.3

The hard way -- Compile from source

If your web hosting provider lets you compile stuff on their server you can try compiling ruby yourself.

$ cd ~
$ wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz
$ tar zxvf ruby-1.8.2.tar.gz
$ cd ruby-1.8.2
$ ./configure --prefix=$HOME/opt/ruby-1.8.2 && make && make install
$ rvm mount ~/opt/ruby-1.8.2 -n 1.8.2
$ rvm use 1.8.2