Install Ruby on Rails on CentOS 7 / Fedora 26 using RVM

4

Ruby is an open-source programming language, more popular these days. Ruby language was designed and developed by Yukihiro “Matz” Matsumoto in mid-1995. This article will help you to install Ruby on Rails on CentOS 7 / RHEL 7 / Fedora 26 / Fedora 25 using RVM (Ruby Version Manager).

RVM provides an easy set of commands to install single or multiple versions of Ruby on a single server.

Table of contents:

1. Install RVM

2. Install Rails

3. Install Node.js

4. Install MySQL Database

5. Create a Test Application

Install RVM

RVM stands for Ruby Version Manager. It provides an efficient way to install and manage ruby version independently. We will use it to install the latest version of Ruby on your system.

Install curl

If your machine does not have curl installed, you can start installing it.

yum install  -y curl gnupg2

Install RVM

Before installing RVM on your system, import public key in your system and then use curl to install RVM in your system.

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable

After installing RVM, we need to load rvm environment variable using below command.

source /etc/profile.d/rvm.sh

Install all the dependencies for installing ruby on the system using below command.

rvm requirements

Run the following command to get a list of available ruby versions that can be installed on the system.

rvm list known

Output:

# 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[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]
ruby-head
.    .    .

With RVM, we can manage multiple ruby versions on the single system. Use the following command to install Ruby 2.4.1.

rvm install 2.4.1

You can also install multiple versions of ruby using the rvm install <version> command.

Run the following command to set version 2.4.1 as the default version of ruby in case your machine has multiple versions of Ruby.

rvm use 2.4.1 --default

Output:

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

Check the current ruby version is used.

ruby --version

Output

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

Install Rails

We can install a latest stable release of Rails by running following command. This process may take a while, be patient with it. Once it finishes you will have Ruby on Rails installed on your system.

gem install rails

Check the rails version.

rails -v

Output:

Rails 5.1.4

You can also install a specific version of rails by using gem install rails –version=<version> command.

Once you have installed Ruby on Rails on Ubuntu, we can create a test application to test it out. To do that, follow below steps.

Install Node.js

Install MySQL Database

Create a Test Application

That’s All. You have successfully installed Ruby on Rails on CentOS 7 / Fedora 26 using RVM.

Further Reading

You might also like
Shares