How to Install Ruby2.2 on CentOS6
This is just a small post to describe how to Install Ruby 2.2 package on CentOS6. Actually by-default package of Ruby on CentOS6 is 1.8 , but some of applications used to install on CentOS6 which require Ruby 2.2 provided features. So we will see How to Install Ruby2.2 on CentOS6 machine.
For this setup we are using CentOS6. although today in Feb 2018, latest is CentOS7 but in many organisation CentOS6 is running on production server on large scale.
We are using CentOS6 , latest as of now Feb 2018
# cat /etc/redhat-release CentOS release 6.9 (Final) # uname -r 2.6.32-696.20.1.el6.x86_64
So we have Ruby 1.8 installed on machine.
# ruby --version ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
As we all know Ruby has its own package manager which could use to install Ruby packages like python has pip package installer. we need to install Rack and Passenger but it ask for Ruby 2.2
# gem install rack passenger ERROR: Error installing rack: rack requires Ruby version >= 2.2.2. ERROR: Error installing passenger: rake requires Ruby version >= 2.0.0.
With this situation we need to install Ruby 2.2 on CentOS6 machine. Now. below Steps to Install Ruby 2.2 on this CentOS which enable us to install Rack and passenger.
Step1 – CentOS SCLo Software collections Repository
We need to Add CentOS SCLo Software collections Repository like mentioned below.
# yum -y install centos-release-scl-rh centos-release-scl
Step2 – Installation of Rubby2.2
Once we add SCLo repository, we can install Ruby2.2 with below mentioned command
# yum install rh-ruby22
Set environment variable
Once we install Ruby2.2 on CentOS6, we just need to set environment variable like mentioned below
# scl enable rh-ruby22 bash # ruby --version ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux-gnu]
Now we can install our gem packages.
# gem install rack passenger Fetching: rack-2.0.4.gem (100%) Successfully installed rack-2.0.4 Parsing documentation for rack-2.0.4 Installing ri documentation for rack-2.0.4 Done installing documentation for rack after 3 seconds Fetching: rake-12.3.0.gem (100%) Successfully installed rake-12.3.0 Fetching: passenger-5.2.0.gem (100%) Building native extensions. This could take a while... Successfully installed passenger-5.2.0 Parsing documentation for rake-12.3.0 Installing ri documentation for rake-12.3.0 Parsing documentation for passenger-5.2.0 Installing ri documentation for passenger-5.2.0 Done installing documentation for rake, passenger after 81 seconds 3 gems installed