How to install Ruby, Ruby on Rails and Phusion Passenger on CentOS

Lately, I have been writing apps in ruby instead of PHP, as it has a low learning curve especially if you know bash scripting and an awesome framework called Rails. Ruby on Rails was so easy to work with that I got my app up and running in 48 hours. You can check it out here I know it's no big deal, but it was fun to build and easy to, Ruby makes programming fun, You can learn it here

Installing Ruby 2.2.2 via RVM
I recommend using RVM, to install Ruby on Linux, this helps you to install and use multiple versions of ruby without having to uninstall and reinstall them.

#Install curl
[leo@linux-vps ~]$ sudo yum install curl
#Install rvm and ruby
[leo@linux-vps ~]$ curl -sSL | bash -s stable --ruby
#Run rvm scripts
[leo@linux-vps ~]$ source /usr/local/rvm/scripts/rvm

This may take time but will install ruby version 2.1.2 as well as RubyGems, a ruby package manager.

Below is a list of rvm command line arguments to troubleshoot issues.

#List installed ruby versions
[leo@linux-vps ~]$rvm list
#Install specific ruby versions
[leo@linux-vps ~]$rvm install 2.1.2
#Find the Directory where gems are installed.
[leo@linux-vps ~]$rvm gemdir
#Use rvmsudo to install gems instead of sudo to avoid enviroment issues.
[leo@linux-vps ~]$rvmsudo gem install sqlite3 -v '1.3.9'

You will need to install sqlite and nodejs for the Ruby on Rails framework.

[leo@linux-vps ~]$sudo yum install sqlite-devel
[leo@linux-vps ~]$rvmsudo gem install sqlite3 -v '1.3.9'
[leo@linux-vps ~]$ sudo yum install nodejs

Installing Rails

#Install rails via the gem package manager
[leo@linux-vps ~]$gem install rails

Once rails is installed create a new rails app and follow the instructions here if you are just getting started with Rails.

#By default Rais will connect to sqllite, you can use -d for mysql
[leo@linux-vps ~]$rails new appname -d mysql

Rails has its own server which you can use for testing your app, but for a live app I highly recommend installing Phusion Passenger, easy to install and can handle a high number of connections.
Installing Phusion Passenger

#Install Phusion Passenger
[leo@linux-vps ~]$rvmsudo gem install passenger
#start passenger on port 80 in daemon mode
[leo@linux-vps ~]$rvmsudo passenger start --daemonize --port 80 --user=leo_g
#Check passenger status
[leo@linux-vps ~]$ rvmsudo passenger status --port 80
Stop passenger
[leo@linux-vps ~]$ rvmsudo passenger stop --port 80




Creative Commons License
All posts Content by Leonard Gonsalves is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at
Permissions beyond the scope of this license may be available at