How to install Ruby on Rails on CentOS 8

How to install Ruby on Rails on CentOS 8

Ruby on Rails is a free open source web application framework that helps you create websites with Ruby. Rails is a model view controller framework that combines the Ruby programming language with JavaScript, HTML, and CSS to write web applications that run on a web server and simplify common repetitive tasks. Rails comes with a set of conventions that can help developers speed up development without spending a lot of time configuring files.

In this tutorial, we will show you how to install the Ruby on Rails framework on a CentOS 8 server.


  • Server 8 running CentOS.
  • A root password is configured on the server.

Install Ruby

The easiest way to install Ruby using RVM. RVM, also known as the “Ruby version manager”, is a command line tool that you can use to install and manage different Ruby versions from the interpreter.

First, install the curl and gnupg2 packages using the following command:

dnf install curl gnupg2 -y

Next, you will need to import the RVM public key on your system:

gpg2 --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

You should see the following output:

gpg: key 105BD0E739499BDB: 8 signatures not checked due to missing keys
gpg: key 105BD0E739499BDB: public key "Piotr Kuczynski <[email protected]>" imported
gpg: key 3804BB82D39DC0E3: 108 signatures not checked due to missing keys
gpg: key 3804BB82D39DC0E3: "Michal Papis (RVM signing) <[email protected]>" not changed
gpg: no ultimately trusted keys found
gpg: Total number processed: 2
gpg:               imported: 1
gpg:              unchanged: 1

Next, download and install the latest stable version of RVM using the following command:

curl -sSL | bash -s stable

Once RVM is installed, you will get the following output:

gpg: Signature made Wednesday 10 July 2019 04:31:02 AM EDT
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/usr/local/rvm/archives/rvm-1.29.9.tgz'
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:

Next, activate the RVM environment variable using the following command:

source /etc/profile.d/

Next, install all Ruby dependencies by running:

rvm requirements

After installing all dependencies, you should see the following output:

Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, autoconf, automake, bison, gcc-c++, libffi-devel, libtool, make, patch, readline-devel, ruby, sqlite-devel, zlib-devel, glibc-headers, glibc-devel, openssl-devel.........................................
Requirements installation successful.

Now you can use the following command to list all available Ruby versions:

rvm list known

You should see the following output:

# MRI Rubies
[ruby-]1.8.7[-head] # security released on head

You can now install Ruby version 2.6.3 using the following command:

rvm install 2.6.3

Next, run the following command to set version 2.6.3 as the default version:

rvm use 2.6.3 --default


Using /usr/local/rvm/gems/ruby-2.6.3

You can also verify the installed version of Ruby using the following command:

ruby --version


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

Install the slide rail

You can install the latest version of Rails using the gem command as follows:

gem install rails

Once Rails is installed, you can check the Rails version using:

rails -v

You should see the following output:


in conclusion

In the above tutorial, you learned how to install Ruby on Rails on a CentOS 8 server. Now you can easily install, manage and use different Ruby versions with RVM. For more information, you can visit the official Ruby documentation at: Ruby documentation.