Cyberithub

How to Install Ruby on CentOS/RedHat 7 in 5 Easy Steps

Advertisements

In this article, I will take you through the steps to install ruby on CentOS/RedHat 7.Ruby is an interpreted, high-level, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.

Ruby is dynamically typed and uses garbage collection. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming. According to the creator, Ruby was influenced by Perl, Smalltalk, Eiffel, Ada, Basic, and Lisp.

Install Ruby on CentOS/RedHat 7

Also Read: Understanding Kafka Console Producer and Consumer in 10 Easy Steps

Step 1 - Prerequisites

a)You need a Running CentOS/RedHat 7 System.

b)You need to have yum installed in your System.

c)You should have sudo access to run privilege commands. To know more about providing sudo access you can check Step by Step: How to Add User to Sudoers.

How to Install Ruby on CentOS/RedHat 7 in 5 Easy Steps 1

Step 2 - Update Your System 

Sometimes installing a new package requires all the libraries and dependencies to be updated to the latest version. Hence firstly you need to update your system using yum update -y command to make sure all the latest updates are installed in the System. If your system is already updated then it will show no updates to be installed.

[root@localhost ~]# yum update -y
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/2): extras/7/x86_64/primary_db | 153 kB 00:00
(2/2): updates/7/x86_64/primary_db | 2.8 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package binutils.x86_64 0:2.27-41.base.el7 will be updated
---> Package binutils.x86_64 0:2.27-41.base.el7_7.1 will be an update
---> Package device-mapper.x86_64 7:1.02.158-2.el7 will be updated
---> Package device-mapper.x86_64 7:1.02.158-2.el7_7.2 will be an update
---> Package device-mapper-event.x86_64 7:1.02.158-2.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.158-2.el7_7.2 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.158-2.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.158-2.el7_7.2 will be an upd ate
---> Package device-mapper-libs.x86_64 7:1.02.158-2.el7 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2 will be an update
---> Package firewalld.noarch 0:0.6.3-2.el7_7.1 will be updated
---> Package firewalld.noarch 0:0.6.3-2.el7_7.2 will be an update
---> Package firewalld-filesystem.noarch 0:0.6.3-2.el7_7.1 will be updated
---> Package firewalld-filesystem.noarch 0:0.6.3-2.el7_7.2 will be an update
---> Package hostname.x86_64 0:3.13-3.el7 will be updated
---> Package hostname.x86_64 0:3.13-3.el7_7.1 will be an update
---> Package kernel.x86_64 0:3.10.0-1062.4.1.el7 will be installed
---> Package kernel-tools.x86_64 0:3.10.0-1062.1.2.el7 will be updated
---> Package kernel-tools.x86_64 0:3.10.0-1062.4.1.el7 will be an update
...........................................................................

Step 3 - Install Ruby through yum

Now you can install ruby in your system using yum install ruby -y command as shown below. This command will search and install all the dependencies as well so that you don't have do install it manually.

[root@localhost ~]# yum install ruby -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:2.0.0.648-36.el7 will be installed
--> Processing Dependency: ruby-libs(x86-64) = 2.0.0.648-36.el7 for package: ruby-2.0.0.648-36.el7.x86_64
--> Processing Dependency: rubygem(bigdecimal) >= 1.2.0 for package: ruby-2.0.0.648-36.el7.x86_64
--> Processing Dependency: ruby(rubygems) >= 2.0.14.1 for package: ruby-2.0.0.648-36.el7.x86_64
--> Processing Dependency: libruby.so.2.0()(64bit) for package: ruby-2.0.0.648-36.el7.x86_64
--> Running transaction check
---> Package ruby-libs.x86_64 0:2.0.0.648-36.el7 will be installed
..............................................................................

Step 4 - Check Ruby Version

Once installation is completed, you can check the installed Ruby Version through ruby --version command as shown below. As you can see from below output, current version is 2.0.0.

[root@localhost ~]# ruby --version
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

Step 5 - Write Your First Ruby Program

After successfully installing ruby in your system, you can now write your First Ruby Program to display Hello World in the output.

[root@localhost ~]# vi hello.rb
puts "Hello World!!"

Output

[root@localhost ~]# ruby hello.rb
Hello World!!

 

Congratulations!!! You have written and executed your first Ruby Program.

 

 

Recommended Posts:-

Popular firewalld examples to open a port on RedHat/CentOS 7

8 Most Popular mkdir command in Linux with Examples

26 Useful Firewall CMD Examples on RedHat/CentOS 7

12 Most Popular rm command in Linux with Examples

9 useful w command in Linux with Examples

Popular Apache Kafka Architecture Explained Using 4 Basic Components

5 Easy Steps to recover LVM2 Partition , PV , VG , LVM metadata in Linux

How to check which timezone in Linux

Ruby Documentation

Difference between Ruby Blocks and Procs

Leave a Comment