Skip to content

How to Install Ruby on CentOS/RHEL 8 and Scientific Linux

Steps
6
Category
Programming
Covers
CentOS, RHEL, Ruby
Versions & support
About Ruby →, About CentOS →
On this page 6 steps

How to Install Ruby on CentOS 8. Ruby is an object-oriented programming language focused on simplicity and productivity. RVM (Ruby Version Manager) is a tool for installing and managing multiple Ruby versions on single operating systems. This tutorial will help you to install RVM on your system. After that install the latest Ruby on CentOS 8. This tutorial will also work with RHEL 8 and Scientific Linux 7.

Step 1 of 6Prerequsities

First of all, install all the required packages for the Ruby installation on your CentOS 8 system. Use the following command to install the required packages:

sudo dnf install gcc-c++ patch readline readline-devel zlib zlib-devel ibffi-devel \
 openssl-devel make bzip2 autoconf automake libtool bison sqlite-devel

Step 2 of 6Install RVM

We can install RVM using a shell script provided by the core team. Now, install the latest stable version of RVM on your system using the following commands. Before installing packages import GPG key on your machine.

curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

After that install the latest stable RVM version on your system using the following command:

curl -L get.rvm.io | bash -s stable

Once the installation finished, run below command to load the RVM environment.

source /etc/profile.d/rvm.sh
rvm reload

Step 3 of 6Verify Dependencies

Verify that all the dependencies are properly installed on your system using the below command. If any missing dependency found the script will automatically install it on your system.

rvm requirements run

Checking requirements for centos.
Requirements installation successful.

Step 4 of 6Install Ruby on CentOS 8

Your CentOS 8 machine is ready for the Ruby installation. Find out the available Ruby version for installation using the below command.

rvm list known

Then install the required Ruby version on your system. Here, I am installing Ruby 2.6 on my CentOS 8 system. You can simply replace the version to below command of your choice and install.

rvm install 2.7

Step 5 of 6Setup Default Ruby Version

First of all, check the currently installed ruby versions on your system. So that we can find which version is using currently by the system and which is set to default.

rvm list 

=* ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

If you have multiple versions of ruby, use the below command to set up the default ruby version to be used by applications.

rvm use 2.7 --default

Using /usr/local/rvm/gems/ruby-2.7.0

Step 6 of 6Verify Active Ruby Version

Using the following command you can check the currently active ruby version.

ruby --version

ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

Congratulation’s, Finally you have successfully installed Ruby on your system. Read our next articles to deploy Ruby with Apache or Ruby with Nginx web server with simple steps.

References:
1. http://rvm.io/rubies/installing

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

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


Back to top