Hi there, if you have been following this series you would roughly know that I am trying to setup a remote Centos server to house my rails apps. After installing Apache, mySQL and Git, we are now ready to install Ruby, RubyGems & Rails.

Deploying Rails to Centos 5

As I like to have multiple versions of Ruby in my system, I am going to install RVM to handle them. But before all that, we should check if ruby already exists. SSH into your remote server and run

 ruby -v

If terminal shoots you back with a Ruby version number you already have Ruby installed and you should move on to installing rails.

Let’s install RVM by running this:

$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

When you are done installing, you should edit your .bash_profile To do just that,

 vim ~/.bash_profile

Hit I to edit the file and paste in the following:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

Now, hit ESC to exit editing mode and SHIFT+Z twice to get out of vim. After this, you should log out of ssh and then log back in again to refresh the session.

When you are back in again, run this

type rvm | head -1

and they should reply with this:

 rvm is a function

If it doesn’t it means that the .bash_profile isn’t updated yet.

 rvm notes

Run this to see if you missed any dependencies for installing ruby. The missing dependencies should be listed out for you. Just follow the instructions before proceeding.

Now you can finally install Ruby,

rvm get head
rvm reload
rvm install 1.8.7
rvm install 1.9.2

Create a separate gemset for all your ruby versions by running:

rvm --create 1.8.7
rvm --create use 1.9.2

And make one of them your default by typing

rvm --default use 1.9

You can also check if ruby is installed by running

 ruby -v

They should be using your default version that you just set.

The good thing about installing RVM is that they automatically include RubyGems for you already. To check this fact,

 which gem
/Users/mhartl/.rvm/rubies/ruby-head/bin/gem

Now you can install Rails!

gem install rails --version 3.0.6

Check if it is installed by running

 rails -v

Now you can has rails. Woot.
Next, we will set up a test application for rails to try and make it work with Passenger.