• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Ruby on CentOS/RHEL 7/6

Written by Rahul, Updated on April 3, 2020

How to Install Ruby on CentOS/RHEL 7/6 . 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. This tutorial will help you to install RVM on your system. After that install the latest Ruby on CentOS and RedHat systems using RVM.

Step 1 – Installing Requirements

First of all, you need to install all required packages for ruby installation on our system using the following command.

yum install gcc-c++ patch readline readline-devel zlib zlib-devel libffi-devel \
 openssl-devel make bzip2 autoconf automake libtool bison sqlite-devel

Step 2 – Install RVM

Now, install the latest stable version of RVM on your system using the following command. This command will automatically download all required files and install them on your system.

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.

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 – Verify Dependencies

Now use the following command to verify all dependencies are properly installed. This will install any missing dependencies on your system.

rvm requirements run

Checking requirements for centos.
Requirements installation successful.

Step 4 – Install Ruby on CentOS

Now, your system is ready for the Ruby installation. You can find 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.7 on my CentOS system. You can simply replace the version to below command of your choice and install.

rvm install 2.7

Step 5 – Setup 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.4.4 [ x86_64 ]
 * ruby-2.5.1 [ x86_64 ]
=> ruby-2.7.0 [ x86_64 ]

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

After that use rvm 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 – Verify 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

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

18 Comments

  1. Avatar suresh Reply
    August 12, 2020 at 10:49 am

    flawless instructions. Thanks.
    Worked without any issues

  2. Avatar Aaron Reid Reply
    May 23, 2020 at 4:23 pm

    best instructions I have seen yet and worked like a charm, thanks!

  3. Avatar xxj Reply
    March 18, 2020 at 8:14 am

    I think “ibffi-devel” should be “libffi-devel”.

  4. Avatar Vasiliy Reply
    February 20, 2020 at 4:09 am

    Thank you man!

  5. Avatar Rick Reply
    September 11, 2019 at 2:46 pm

    So good

  6. Avatar Roman Reply
    June 13, 2019 at 6:50 am

    Nice instruction! Thanks!

  7. Avatar Neo Reply
    June 12, 2019 at 6:34 pm

    Thank you so much for these precise instructions!
    Worked like a charm 🙂

  8. Avatar Ram Reply
    June 3, 2019 at 9:11 pm

    Thanks

  9. Avatar Alysson Vicuña Reply
    January 8, 2019 at 11:50 am

    Thx! Congratulations for your post! This post resolve my problem.

  10. Avatar PhilS Reply
    October 21, 2018 at 1:39 am

    Spot on. Thanks for this post man. Been a while since I have used Cent so this was very helpful.

  11. Avatar Manal Shaikh Reply
    October 7, 2018 at 9:02 am

    Thank you so much for this tutorial.

  12. Avatar Eric Reply
    August 28, 2018 at 8:53 pm

    This guide is better than the one in the Ruby website.

  13. Avatar kirby Reply
    July 27, 2018 at 7:42 pm

    It really works! Thank you!

  14. Avatar IC Reply
    June 24, 2018 at 12:41 pm

    Thanks!
    How can I generally “ruby install latest”?

  15. Avatar Shyam Reply
    May 1, 2018 at 3:05 am

    Thank you for the detailed info. it was such a hassle to update ruby; your steps helped to quickly update without any errors.

  16. Avatar SBA Reply
    December 7, 2017 at 10:25 am

    In my case (CentOS 7.2), the /etc/profile/rvm.sh was not created by the automated installer.
    It was just added to my user home .profile file. (/home/myUser/.profile).
    So the command became, source /home/myUser/.profile.

  17. Avatar Jim Reply
    November 16, 2017 at 4:56 pm

    Appreciate the time spent on this. Thanks Rahul!

  18. Avatar David Reply
    May 2, 2017 at 5:38 pm

    Thank you so much!

    I had been running Ruby 1.8.7 (the default) on CentOs 6.9.

    I followed your instructions exactly, and it worked flawlessly. I am now running Ruby 2.4 and my Ruby programs are working! Thank you so much.

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy