Easiest way to install Ruby 2.2 on CentOS 6.x
The easiest way I've found by far to install Ruby on CentOS is by using the Software Collections - here's a link for the Ruby 2.2 collection.
This is how I did it on CentOS 6.x:
1. First install the collections utilities:
yum install scl-utils -y
2. Then install the Ruby 2.2 collection repository:
yum install https://www.softwarecollections.org/en/scls/rhscl/rh-ruby22/epel-6-x86_64/download/rhscl-rh-ruby22-epel-6-x86_64.noarch.rpm -y
3. Now use that repository to install Ruby:
yum install rh-ruby22 rh-ruby22-ruby-devel zlib-devel -y
4. Also install the CentOS Development tools group so you don't hit any dependencies issues:
yum groupinstall Development tools -y
5. Add the correct paths in /opt/rh/rh-ruby22/enable:
echo 'export PATH=/opt/rh/rh-ruby22/root/usr/local/bin${PATH:+:${PATH}}' >> /opt/rh/rh-ruby22/enable
6. Now add the enable script on your ~/.bashrc
so that Ruby is automatically enabled every time you login:
echo "source /opt/rh/rh-ruby22/enable" >> ~/.bashrc
7. Finally source the enable script so you can start using Ruby 2.2 right away:
source /opt/rh/rh-ruby22/enable
8. Test:
ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux-gnu]
gem -v
2.4.5
Awesome :)