How to Install Ruby on CentOS 7

Install Ruby on CentOS 7

In this article, we will have explained the necessary steps to install and configure Ruby on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Ruby is a dynamic, 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.

Install Ruby on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

Step 2. Install Ruby on CentOS 7.

  • Install Ruby using Rbenv

Before starting using rbenv we need to add $HOME/.rbenv/bin to our PATH:

The current latest stable version for Ruby is 2.6.1 at the time of writing this tutorial. Run below command to install Ruby:

Verify that Ruby was properly installed by printing the version number:

  • Install Ruby from CentOS Repository

The easiest way to install Ruby on your CentOS system is through the yum package manager. At the time of writing, the version in the CentOS repositories is 2.0.0 which is pretty outdated:

Once the installation is completed, you can verify that it was successful by printing the Ruby version:

We have shown you two different ways to install Ruby on your CentOS 7 server. The method you choose depends on your requirements and preferences.

Congratulation, you have learned how to install and configure Ruby on CentOS 7. If you have any question, please leave a comment below.