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.
sudo yum install epel-release sudo yum update sudo yum install git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
Step 2. Install Ruby on CentOS 7.
- Install Ruby using Rbenv
curl -sL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash -
Before starting using rbenv we need to add $HOME/.rbenv/bin to our PATH:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc source ~/.bashrc
The current latest stable version for Ruby is 2.6.1 at the time of writing this tutorial. Run below command to install Ruby:
rbenv install 2.6.1 rbenv global 2.6.1
Verify that Ruby was properly installed by printing the version number:
ruby -v
- 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:
sudo yum install ruby
Once the installation is completed, you can verify that it was successful by printing the Ruby version:
sudo ruby install ruby
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.