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
- Part 1 // Apache
- Part 2 // mySQL
- Part 3 // Git
- You are here!
- Part 5 // Passenger
- Part 6 // Gitosis
- Part 7 // Capistrano
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 [shell] ruby -v[/shell]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: [shell]$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)[/shell]
When you are done installing, you should edit your
.bash_profile To do just that, [shell] vim ~/.bash_profile[/shell] Hit I to edit the file and paste in the following:[shell][[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm” # This loads RVM into a shell session.[/shell]
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 [shell]type rvm | head -1[/shell] and they should reply with this: [shell] rvm is a function[/shell] If it doesn’t it means that the
.bash_profile isn’t updated yet.
[shell] rvm notes[/shell]
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, [shell]rvm get head
rvm install 1.8.7
rvm install 1.9.2[/shell]
Create a separate gemset for all your ruby versions by running: [shell]
rvm –create 1.8.7
rvm –create use 1.9.2
And make one of them your default by typing [shell]rvm –default use 1.9[/shell] You can also check if ruby is installed by running [shell] ruby -v[/shell] 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, [shell] which gem
Now you can install Rails!
[shell]gem install rails –version 3.0.6[/shell]
Check if it is installed by running [shell] rails -v[/shell]
Now you can has rails. Woot.
Next, we will set up a test application for rails to try and make it work with Passenger.