How to install Ruby on CentOS 8

Ruby is one of the most popular languages today. It has a concise syntax and is the language behind the Ruby on Rails framework.

In this article, we will explore different ways to install Ruby on CentOS 8.

We will show how to install Ruby through CentOS 8 source repositories, using Rbenv, and using RVM scripts. Choose the installation method that best suits your environment.

1. Install Ruby from CentOS source repository

This is the easiest way to install on CentOS. At the time of writing, the Ruby version on the standard CentOS source repository is 2.5.5.

As root or another user with sudo privileges, run the following command to install the ruby package:

sudo dnf install ruby

Once the installation is complete, you can verify whether Ruby is successfully installed by printing the Ruby version number.

ruby --version

The output should look like this:

ruby 2.5.5p157(2019-03-15 revision 67260)[x86_64-linux]

Your Ruby version number may be different from the one shown above.

that's it. You have successfully installed Ruby on your CentOS system and can start using it.

Two, use Rbenv to install Ruby

Rbenv is a lightweight Ruby version management tool that allows you to switch Ruby versions easily.

We will use the ruby-build plugin to extend the core functionality of Rbenv and allow you to install any Ruby version from source.

Install git and other dependencies necessary to compile Ruby from source.

sudo dnf install git wget gcc bzip2 openssl-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel

Run the following command to install rbenv and ruby-build:

wget -q https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer -O-| bash

This script will clone the rbenv and ruby-build source code from Github to the ~/.rbenv directory.

Before you start using rbenv, you need to add $HOME/.rbenv/bin to your PATH.

If you are using Bash, enter:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"'>>~/.bashrc
echo 'eval "$(rbenv init -)"'>>~/.bashrc
source ~/.bashrc

If you are using Zsh, enter:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"'>>~/.zshrc
echo 'eval "$(rbenv init -)"'>>~/.zshrc
source ~/.zshrc

Run the rbenv -v command to ensure that the installation is successful:

rbenv -v

The output is as follows:

rbenv 1.1.2-17-g7795476

To get all installable Ruby versions installed via rbenv, type:

rbenv install -l

For example, if you want to install Ruby 2.7.0 and set it as the default version, you can enter:

rbenv install 2.7.0
rbenv global 2.7.0

Print the Ruby version number to verify that Ruby is installed correctly:

ruby -v

Output:

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

Three, use RVM to install Ruby

RVM (Ruby Version Manager) is a command line tool that allows you to install, manage and use multiple Ruby environments.

First, install the dependencies necessary for rvm to build Ruby from source code:

sudo dnf install curl gcc bzip2 openssl-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel

Run the following command to import the GPG public key and install RVM:

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

To start using RVM, you need to run the following source command:

source ~/.rvm/scripts/rvm

To get all known Ruby versions, type:

rvm list known

For this example, if you want to install Ruby 2.6 and set it as the default version, you can trigger the following command:

rvm install 2.6
rvm use 2.6--default

Verify the installation:

ruby -v

The output is as follows:

ruby 2.6.3p62(2019-04-16 revision 67580)[x86_64-linux]

For more information on how to use RVM to manage Ruby installations, please visit RVM Documentation Page.

Four, summary##

We have shown you three different ways to install Ruby on your CentOS 8 server. You choose one of these methods according to your requirements and preferences. Even though the way to install Ruby through CentOS source repositories is relatively simple, Rbenv and RVM methods give you more choices. You can add or remove different Ruby versions for each user.

Recommended Posts

How to install Ruby on CentOS 8
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install Ruby on Ubuntu 20.04
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install OpenCV on CentOS 8
How to install PHP on CentOS 8
How to install MongoDB on CentOS 8
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
[Graphic] How to install tomcat on centos
R&D: How To Install Python 3 on CentOS 7
How to install GCC compiler on CentOS 7
How to install offline JDK1.8 on centos7.0
How to install and configure Elasticsearch on CentOS 7
How to install Visual Studio Code on CentOS 8
How to install and use Docker on CentOS 7
How to install RPM packages on CentOS Linux
How to install and configure VNC on CentOS 8
How to install and use Composer on CentOS 8
How to install and configure Redis on CentOS 8
How to install Node.js and npm on CentOS 8
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
How to install and configure phpMyAdmin on CentOS 6
How to install and use Curl on CentOS 8
How to install and configure Owncloud on CentOS 8
How to install VirtualBox client extension on CentOS 8
How to install Docker CE on RHEL 8 / CentOS 8
How to install and uninstall tomcat on centos
How to install and configure Redmine on CentOS 8
How to install Memcached on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04