Install ruby 2.4 with rbenv on CentOS/RHEL 7/6

In this tutorial, we will install ruby 2.4 with rbenv on Centos /RHEL 7/6.

Ruby is a dynamic, interpreted, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro “Matz” Matsumoto in Japan.

According to the creator, Ruby was influenced by Perl, Smalltalk, Eiffel, Ada, and Lisp. It supports multiple programming paradigms, including functional, object-oriented, and imperative.

Read Also: Install ruby 2.4 with rvm on Centos/RHEL 7/6


There are few prerequisites that you need to install before.

yum install git

Install rbenv

Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production. Put rbenv to work with Bundler for painless Ruby upgrades and bulletproof deployments.

git clone ~/.rbenv

Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.

echo'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

Set up rbenv in your shell.

~/.rbenv/bin/rbenv init

Execute the following command to install ruby-build.

git clone ~/.rbenv/plugins/ruby-build

Verify installation

You can use the rbenv doctor to verify if it’s installed properly.

curl -fsSL | bash

Install Ruby 2.4.1

Now after successful installation of rbenv now we will install ruby and manage ruby using rbenv.

rbenv install 2.4.1
Downloading ruby-2.4.1.tar.bz2...
Installing ruby-2.4.1...
Installed ruby-2.4.1 to /root/.rbenv/versions/2.4.1

Set default Ruby

After installation of ruby 2.4.1, we will set it up as default ruby version.

rbenv global 2.4.1

Use the above command to set ruby version globally.

rbenv local 2.4.1

Use the above command to application-specific ruby version.

Check Ruby Version

ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
which ruby

List Ruby Versions

To list all installed ruby versions use the following command.

rbenv versions
* 2.4.1 (set by /root/.rbenv/version)

Now you have successfully installed ruby 2.4.1.

If you have any issue using this tutorial please feel free to comment below.


Leave a Reply

Your email address will not be published.


The reCAPTCHA verification period has expired. Please reload the page.

48-Hour Flash Sale! Courses from just $10.99