Hamsa K
Editor
6 min read | 4 years ago

How to Install Ruby on Rails on Centos 8

How to Install ruby on Rails on centos 8/ Rhel 8

Ruby is a dynamic, multi-purpose, free, and open-source programming language that is usually used for the development of web applications.

Rails is a web application development framework written in the Ruby programming language.It is designed to make programming web applications easier by making assumptions about what every developer needs to get started.

prerequisites:

make sure you logged in with root user or user with sudo privileges.

Step1 : Install Ruby

First we will install dependency packages with the following commands.

[root@localhost ~]# dnf update
[root@localhost ~]# dnf install curl gnupg2 

Next, we will install ruby using rvm (ruby version manager).RVM is a command line tool that allows us to install, manage, and work with different ruby environment.

First we need to import the RVM public key on your system with following command.

gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

sample output:

[root@localhost ~]# gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: key 105BD0E739499BDB: 8 signatures not checked due to missing keys
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 105BD0E739499BDB: public key "Piotr Kuczynski <piotr.kuczynski@gmail.com>" imported
gpg: can't connect to the agent: IPC connect call failed
gpg: key 3804BB82D39DC0E3: 108 signatures not checked due to missing keys
gpg: key 3804BB82D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 2
gpg:               imported: 2

Now download & install latest stable version of RVM with below command.

[root@localhost ~]# curl -sSL https://get.rvm.io | bash -s stable

sample output:

[root@localhost ~]# curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.10.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.10/1.29.10.tar.gz.asc
gpg: Signature made Thu 26 Mar 2020 03:28:42 AM IST
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>" [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.10.tgz'
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete

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

usermod -a -G rvm root

you can change user name instead of root.

Now we will activate the RVM environment variable with the following command

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

Then reload rvm

rvm reload

Next, we will install all ruby package requirements 

[root@localhost ~]# rvm requirements

sample output:

[root@localhost ~]# rvm requirements
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, bison, libffi-devel, patch, readline-devel, ruby, sqlite-devel...............
Requirements installation successful.

Now we will check all available ruby versions with below command

[root@localhost ~]# rvm list known

sample output

[root@localhost ~]# 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

we will install latest version 2.7.0 with the following command

[root@localhost ~]# rvm install 2.7.0

once it is installed set it as default version with below command

[root@localhost ~]# rvm use 2.7.0 --default

Now, Finally we will check version of ruby with 'ruby --version' command.

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

Step 2: Install Rails

you can install the latest version of Rails using the gem command

[root@localhost ~]# gem install rails

check rails version using 'rails -v' command.

[root@localhost ~]# rails -v
Rails 6.0.3.2

Thats'it.Now you have learned how to install ruby on rails on centos server.

 


Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy