We have already discussed about Ruby installation steps on previous post. There are several tools available to install Ruby, this page describes how to build ruby 2.2.2 with RVM on CentOS 6 or CentOS 7.

Before that, we need to install all necessary package using YUM command,

root@host [~]# sudo yum install -y git-core zlib zlib-devel gcc-c++ patch

root@host [~]# sudo yum install readline readline-devel libyaml-devel libffi-devel

root@host [~]# sudo yum install  openssl-devel make bzip2 autoconf automake

root@host [~]# sudo yum install  libtool bison curl sqlite-devel


Install recent version RVM using the below command, the below command download and install supporting packages.

root@host [~]#  curl -sSL https://rvm.io/mpapis.asc | gpg --import -


gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
root@host [~]# curl -L get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22721  100 22721    0     0  14436      0  0:00:01  0:00:01 --:--:-- 59635
........

........
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:

  * First you need to add all users that will be using rvm to 'rvm' group,
    and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.

  * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

# Administrator,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.
In case of problems: http://rvm.io/help and https://twitter.com/rvm_io


Now, setup the rvm environment, run the below command and reload rvm.
 

root@host [~]# source /etc/profile.d/rvm.sh

root@host [~]# rvm reload
RVM reloaded!

To check all the dependencies installed on your system,
 
root@host [~]#  rvm requirements run

Once you have verified the rvm environment  to instlal Ruby without any errors.
 
root@host [~]#  rvm install 2.2.2

Searching for binary rubies, this might take some time.
No binary rubies available for: centos/6/x86_64/ruby-2.2.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.2.2, this may take a while depending on your cpu(s)...
ruby-2.2.2 - #downloading ruby-2.2.2, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.6M  100 12.6M    0     0  7081k      0  0:00:01  0:00:01 --:--:-- 12.0M
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.2.2 - #extracting ruby-2.2.2 to /usr/local/rvm/src/ruby-2.2.2....
ruby-2.2.2 - #configuring.........................................................
ruby-2.2.2 - #post-configuration..
ruby-2.2.2 - #compiling....................................................................................
ruby-2.2.2 - #installing............................
ruby-2.2.2 - #making binaries executable..
ruby-2.2.2 - #downloading rubygems-2.4.8
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  437k  100  437k    0     0   606k      0 --:--:-- --:--:-- --:--:-- 1613k
.........
.........
Install of ruby-2.2.2 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri


Finally, check your Ruby version,
 
# ruby -version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]