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 the RPM package if you need it.
Install Ruby 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 to 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. Thank you for reading the DevopsRoles page!
1 thought on “How to Install Ruby on CentOS/RHEL”