Reading Time: 8 minutes

Today we’re going to install Ruby on Rails using RVM (the Ruby Version Manager) onto a CentOS 8 server. Let's start by defining a few terms and definitions we will be using during the process.

What Is Ruby?

Ruby is defined as “a dynamic, reflective, interpreted, high-level programming language. The language has a multi-threading implementation independent of the operating system, strong dynamic typing, a garbage collector, and many other features. It is one of the most popular programming languages. It has an elegant syntax that is nice to read and easy to write. And programmers rate it with the highest satisfaction mark.

What Is Ruby on Rails?

Ruby on Rails is defined as “a framework written in the Ruby programming language that implements the Model-View-Controller architectural template for web applications, as well as integrates them with a web server and database server. This is the most popular Ruby framework. It combines well with JavaScript, HTML, and CSS, runs on a web server, and simplifies frequent tasks.

Prerequisites

  • Ruby
  • Tar
  • RVM or Gem
  • gnupg2

Installation

We will start our installation process with updating the current packages on our system.

[root@host ~]# dnf update
Failed to set locale, defaulting to C.UTF-8
CentOS-8 - AppStream                        	12 kB/s | 4.3 kB 	00:00	
CentOS-8 - Base                            	9.8 kB/s | 3.8 kB 	00:00	
CentOS-8 - Extras                          	3.8 kB/s | 1.5 kB 	00:00   
Dependencies resolved.
Nothing to do.
Complete!
[root@host ~]#

Next, we need to ensure the following packages are installed and up to date. We will not install Ruby in this next command but will install it shortly.

  • Curl 
  • gnupg2
  • tar

To install these packages, we will use the following command.

[root@host ~]# dnf install curl gnupg2 tar
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:00:41 ago on Wed Mar  4 01:41:33 2020.
Package curl-7.61.1-11.el8.x86_64 is already installed.
Package gnupg2-2.2.9-1.el8.x86_64 is already installed.
Dependencies resolved.
======================================================================
 Package       Architecture 	Version             	Repository    	Size
======================================================================
Installing:
 tar           x86_64       	2:1.30-4.el8        	BaseOS       	838 k
 
Transaction Summary
======================================================================
Install  1 Package
 
Total download size: 838 k
Installed size: 2.8 M
Is this ok [y/N]: y
Downloading Packages:
tar-1.30-4.el8.x86_64.rpm                  	2.9 MB/s | 838 kB 	00:00   
----------------------------------------------------------------------
Total                                      	1.5 MB/s | 838 kB 	00:00 	
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing    	:                        	                           1/1
  Installing   	: tar-2:1.30-4.el8.x86_64                           	1/1
  Running scriptlet: tar-2:1.30-4.el8.x86_64                           	1/1
  Verifying    	: tar-2:1.30-4.el8.x86_64                	           1/1
 
Installed:
  tar-2:1.30-4.el8.x86_64                                              
 
Complete!
[root@host ~]#

What is RVM (“Ruby Version Manager”)

We will be installing Ruby on Rails using RVM (or the Ruby Version Machine). RVM is a command line tool that allows us to install, manage, and work with different ruby environments.

RVM is similar to dnf, snappy, or Pypi. RVM allows you to install and manage multiple installations of Ruby on your system. It can also manage different gemsets. It is available for macOS, Linux, or other UNIX-like operating systems. Our next step is to download the RVM startup script

Note:
As always, be sure to verify the commands of any bash script before running it from an external source.
[root@host ~]# curl -sSL https://get.rvm.io | bash
Downloading https://github.com/rvm/rvm/archive/master.tar.gz
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:
 
  * First you need to add all users that will be using rvm to 'rvm' group,
	and logout - login again, anyone using rvm will be operating with umask u=rwx,g=rwx,o=rx.
 
  * To start using RVM you need to run source /etc/profile.d/rvm.sh
	in all your open shell windows, in rare cases you need to reopen all shell windows.
  * Please do NOT forget to add your users to the rvm group.
 	The installer no longer auto-adds root or users to the rvm group. Admins must do this.
 	Also, please note that group memberships are ONLY evaluated at login time.
 	This means that users must log out then back in before group membership takes effect!
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
 
👉  Donate: https://opencollective.com/rvm/donate

Now, we will need to add a user who will utilize the RVM group.

[root@host ~]# usermod -a -G rvm root
[root@host ~]#

Moving forward, we're going to update system environment variables.

[root@host ~]# source /etc/profile.d/rvm.sh
[root@host ~]#

Next, we will need to install the package requirements for Ruby

[root@host ~]# rvm requirements
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, autoconf, automake, bison, bzip2, gcc-c++, libffi-devel, libtool, make, patch, readline-devel, ruby, sqlite-devel, zlib-devel, glibc-headers, glibc-devel, openssl-devel...............................-
Requirements installation successful.

Ruby Installation

We will start the installation by checking the available versions of Ruby.

[root@host ~]# rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.9]
[ruby-]2.5[.7]
[ruby-]2.6[.5]
[ruby-]2.7[.0]
ruby-head
 
# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
 
# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby-9.1[.17.0]
jruby[-9.2.11.0]
jruby-head
 
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.107]
rbx-4[.12]
rbx-head
 
# TruffleRuby
truffleruby[-20.0.0]
 
# Opal
opal
 
# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
mruby-1.3.0
mruby-1[.4.1]
mruby-2.0.1
mruby-2[.1.0]
mruby[-head]
 
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
 
# Topaz
topaz
 
# MagLev
maglev-1.0.0
maglev-1.1[RC1]
maglev[-1.2Alpha4]
maglev-head
 
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
 
# IronRuby
ironruby[-1.1.3]
ironruby-head
[root@host ~]#

The most recent, and stable version is 2.7.0. We can install it by running the following RVM command.

[root@host ~]# rvm install 2.7.0
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/8/x86_64/ruby-2.7.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.7.0, this may take a while depending on your cpu(s)...
ruby-2.7.0 - #downloading ruby-2.7.0, this may take a while depending on your connection...
  % Total	% Received % Xferd  Average Speed   Time    Time 	Time  Current
                             	Dload  Upload   Total   Spent	Left  Speed
100 14.0M  100 14.0M	0     0  10.1M  	0  0:00:01  0:00:01 --:--:-- 10.1M
ruby-2.7.0 - #extracting ruby-2.7.0 to /usr/local/rvm/src/ruby-2.7.0.....
ruby-2.7.0 - #configuring.....................................................-
ruby-2.7.0 - #post-configuration..
ruby-2.7.0 - #compiling.......................................................-
ruby-2.7.0 - #installing..................
ruby-2.7.0 - #making binaries executable...
Installed rubygems 3.1.2 is newer than 3.0.8 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.7.0 - #gemset created /usr/local/rvm/gems/ruby-2.7.0@global
ruby-2.7.0 - #importing gemset /usr/local/rvm/gemsets/global.gems.............-
ruby-2.7.0 - #generating global wrappers.......
ruby-2.7.0 - #gemset created /usr/local/rvm/gems/ruby-2.7.0
ruby-2.7.0 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.7.0 - #generating default wrappers.......
ruby-2.7.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.7.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
[root@host ~]#

Now, let’s set the default version of Ruby.

[root@host ~]# rvm use 2.7.0 --default
Using /usr/local/rvm/gems/ruby-2.7.0
[root@host ~]#

After installation, we can double-check whether it was installed and its version.

[root@host ~]# ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
[root@host ~]#

Now, we can install Rails.

[root@host ~]# gem install rails
Fetching i18n-1.8.2.gem
Fetching mini_portile2-2.4.0.gem
Fetching nokogiri-1.10.9.gem
Fetching concurrent-ruby-1.1.6.gem
Fetching loofah-2.4.0.gem
Fetching rails-html-sanitizer-1.3.0.gem
Fetching crass-1.0.6.gem
Fetching zeitwerk-2.3.0.gem
Fetching erubi-1.9.0.gem
Fetching rack-test-1.1.0.gem
Fetching activesupport-6.0.2.1.gem
Fetching thread_safe-0.3.6.gem
Fetching rails-dom-testing-2.0.3.gem
Fetching actionview-6.0.2.1.gem
Fetching rack-2.2.2.gem
Fetching tzinfo-1.2.6.gem
Fetching builder-3.2.4.gem
Fetching activemodel-6.0.2.1.gem
Fetching activerecord-6.0.2.1.gem
Fetching globalid-0.4.2.gem
Fetching actionpack-6.0.2.1.gem
Fetching actioncable-6.0.2.1.gem
Fetching mini_mime-1.0.2.gem
Fetching mail-2.7.1.gem
Fetching activejob-6.0.2.1.gem
Fetching actionmailbox-6.0.2.1.gem
Fetching nio4r-2.5.2.gem
Fetching websocket-extensions-0.1.4.gem
Fetching websocket-driver-0.7.1.gem
Fetching actionmailer-6.0.2.1.gem
Fetching sprockets-4.0.0.gem
Fetching marcel-0.3.3.gem
Fetching activestorage-6.0.2.1.gem
Fetching mimemagic-0.3.4.gem
Fetching thor-1.0.1.gem
Fetching method_source-0.9.2.gem
Fetching rails-6.0.2.1.gem
Fetching railties-6.0.2.1.gem
Fetching actiontext-6.0.2.1.gem
Fetching sprockets-rails-3.2.1.gem
Successfully installed concurrent-ruby-1.1.6
 
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.
 
If you are upgrading your Rails application from an older version of Rails:
 
Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.
 
If you are starting a NEW Rails application, you can ignore this notice.
 
For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
 
Successfully installed i18n-1.8.2
Successfully installed thread_safe-0.3.6
Successfully installed tzinfo-1.2.6
Successfully installed zeitwerk-2.3.0
Successfully installed activesupport-6.0.2.1
Successfully installed rack-2.2.2
Successfully installed rack-test-1.1.0
Successfully installed mini_portile2-2.4.0
Building native extensions. This could take a while...
Successfully installed nokogiri-1.10.9
Successfully installed crass-1.0.6
Successfully installed loofah-2.4.0
Successfully installed rails-html-sanitizer-1.3.0
Successfully installed rails-dom-testing-2.0.3
Successfully installed builder-3.2.4
Successfully installed erubi-1.9.0
Successfully installed actionview-6.0.2.1
Successfully installed actionpack-6.0.2.1
Successfully installed activemodel-6.0.2.1
Successfully installed activerecord-6.0.2.1
Successfully installed globalid-0.4.2
Successfully installed activejob-6.0.2.1
Successfully installed mini_mime-1.0.2
Successfully installed mail-2.7.1
Successfully installed actionmailer-6.0.2.1
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.2
Successfully installed websocket-extensions-0.1.4
Building native extensions. This could take a while...
Successfully installed websocket-driver-0.7.1
Successfully installed actioncable-6.0.2.1
Successfully installed mimemagic-0.3.4
Successfully installed marcel-0.3.3
Successfully installed activestorage-6.0.2.1
Successfully installed actionmailbox-6.0.2.1
Successfully installed actiontext-6.0.2.1
Successfully installed thor-1.0.1
Successfully installed method_source-0.9.2
Successfully installed railties-6.0.2.1
Successfully installed sprockets-4.0.0
Successfully installed sprockets-rails-3.2.1
Successfully installed rails-6.0.2.1
Parsing documentation for concurrent-ruby-1.1.6
Installing ri documentation for concurrent-ruby-1.1.6
Parsing documentation for i18n-1.8.2
Installing ri documentation for i18n-1.8.2
Parsing documentation for thread_safe-0.3.6
Installing ri documentation for thread_safe-0.3.6
Parsing documentation for tzinfo-1.2.6
Installing ri documentation for tzinfo-1.2.6
Parsing documentation for zeitwerk-2.3.0
Installing ri documentation for zeitwerk-2.3.0
Parsing documentation for activesupport-6.0.2.1
Installing ri documentation for activesupport-6.0.2.1
Parsing documentation for rack-2.2.2
Installing ri documentation for rack-2.2.2
Parsing documentation for rack-test-1.1.0
Installing ri documentation for rack-test-1.1.0
Parsing documentation for mini_portile2-2.4.0
Installing ri documentation for mini_portile2-2.4.0
Parsing documentation for nokogiri-1.10.9
Installing ri documentation for nokogiri-1.10.9
Parsing documentation for crass-1.0.6
Installing ri documentation for crass-1.0.6
Parsing documentation for loofah-2.4.0
Installing ri documentation for loofah-2.4.0
Parsing documentation for rails-html-sanitizer-1.3.0
Installing ri documentation for rails-html-sanitizer-1.3.0
Parsing documentation for rails-dom-testing-2.0.3
Installing ri documentation for rails-dom-testing-2.0.3
Parsing documentation for builder-3.2.4
Installing ri documentation for builder-3.2.4
Parsing documentation for erubi-1.9.0
Installing ri documentation for erubi-1.9.0
Parsing documentation for actionview-6.0.2.1
Installing ri documentation for actionview-6.0.2.1
Parsing documentation for actionpack-6.0.2.1
Installing ri documentation for actionpack-6.0.2.1
Parsing documentation for activemodel-6.0.2.1
Installing ri documentation for activemodel-6.0.2.1
Parsing documentation for activerecord-6.0.2.1
Installing ri documentation for activerecord-6.0.2.1
Parsing documentation for globalid-0.4.2
Installing ri documentation for globalid-0.4.2
Parsing documentation for activejob-6.0.2.1
Installing ri documentation for activejob-6.0.2.1
Parsing documentation for mini_mime-1.0.2
Installing ri documentation for mini_mime-1.0.2
Parsing documentation for mail-2.7.1
Installing ri documentation for mail-2.7.1
Parsing documentation for actionmailer-6.0.2.1
Installing ri documentation for actionmailer-6.0.2.1
Parsing documentation for nio4r-2.5.2
Installing ri documentation for nio4r-2.5.2
Parsing documentation for websocket-extensions-0.1.4
Installing ri documentation for websocket-extensions-0.1.4
Parsing documentation for websocket-driver-0.7.1
Installing ri documentation for websocket-driver-0.7.1
Parsing documentation for actioncable-6.0.2.1
Installing ri documentation for actioncable-6.0.2.1
Parsing documentation for mimemagic-0.3.4
Installing ri documentation for mimemagic-0.3.4
Parsing documentation for marcel-0.3.3
Installing ri documentation for marcel-0.3.3
Parsing documentation for activestorage-6.0.2.1
Installing ri documentation for activestorage-6.0.2.1
Parsing documentation for actionmailbox-6.0.2.1
Installing ri documentation for actionmailbox-6.0.2.1
Parsing documentation for actiontext-6.0.2.1
Installing ri documentation for actiontext-6.0.2.1
Parsing documentation for thor-1.0.1
Installing ri documentation for thor-1.0.1
Parsing documentation for method_source-0.9.2
Installing ri documentation for method_source-0.9.2
Parsing documentation for railties-6.0.2.1
Installing ri documentation for railties-6.0.2.1
Parsing documentation for sprockets-4.0.0
Installing ri documentation for sprockets-4.0.0
Parsing documentation for sprockets-rails-3.2.1
Installing ri documentation for sprockets-rails-3.2.1
Parsing documentation for rails-6.0.2.1
Installing ri documentation for rails-6.0.2.1
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, zeitwerk, activesupport, rack, rack-test, mini_portile2, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, mimemagic, marcel, activestorage, actionmailbox, actiontext, thor, method_source, railties, sprockets, sprockets-rails, rails after 34 seconds
40 gems installed
[root@host ~]#

Next, we can check the version of Rails we just installed by using the following command.

[root@host ~]# rails -v
Rails 6.0.2.1
[root@host ~]#

If we want to use a specific version of Rails, we can use the following command.

[root@host ~]# gem install rails –v [insert.number.version]

Conclusion

Now that we have Ruby on Rails installed on the server, we can begin using it as a powerful foundation for our Ruby application development. After installing Ruby on Rails, you can start creating an SSL certificate or installing an FTP server.

Should you experience any issues with install, you can always give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable systems administrators today!

Avatar for Ellen Sletton

About the Author: Ellen Sletton

I'm 23 years old Linux Tech who always takes NO as Next Opportunity. Every day I'm trying to learn something new and share my knowledge with others. My free time I spend with my dog Emil or doing some UI/UX design or simply making an inspiring photo for my blog :) Sharing knowledge helps me generate new ideas and stay motivated.

Latest Articles

In-place CentOS 7 upgrades

Read Article

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article