How to Install Ruby on CentOS/RHEL

In this tutorial, How to Install Ruby on CentOS/RHEL. The default in CentOS 7 repository is ruby version 2.0. You can install 2.5 with RPM package if you need.

Install Ruby 2.5 on CentOS/RHEL

Add CentOS SCLo Repository

[vagrant@DevopsRoles ~]# yum -y install centos-release-scl-rh centos-release-scl

Install and configure Ruby 2.5

# Packages installed uder the /opt directory
[vagrant@DevopsRoles ~]# yum --enablerepo=centos-sclo-rh -y install rh-ruby25
# load environment variables
[vagrant@DevopsRoles ~]# scl enable rh-ruby25 bash
[vagrant@DevopsRoles ~]# ruby -v 
[vagrant@DevopsRoles ~]# which ruby

Note: If you like enable Ruby 2.5 auto at login time, Configure as below

[vagrant@DevopsRoles ~]# vi /etc/profile.d/rh-ruby25.sh
# create new the content as below

#!/bin/bash
source /opt/rh/rh-ruby25/enable
export X_SCLS="$(scl enable rh-ruby25 'echo $X_SCLS')"

You have installed Ruby On CentOS/RHEL 🙂

, , ,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

1 thought on “How to Install Ruby on CentOS/RHEL

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.