How to Install Ruby on Rails CentOS 8 Tutorial (Step by Step)

How to Install Ruby on Rails CentOS 8. There is plenty of scripting languages and web frameworks that aid web development process.  In this post we will understand what RoR is with the tool features and move onto installation part with CentOS 8. 

What is Ruby on Rails

Ruby on Rails is an open source framework used for developing server side web applications. It is relatively popular among startups since it helps in developing prototypes and Minimum Viable Products (MVPs) rapidly. It enables the developers to use its ready made solutions and helps to save programming time.

Rails server act as Ruby’s top layer and enables web developers to build unique web applications. The framework operates in a Model View Controller (MVC) environment, which has one of the best design principles. It can separate business logic from the databases, queries, and UI UX code effortlessly.

After its introduction in 2005, the entire web developing world was introduced to its new and unique features. Its Convention Over Configuration (CoC) ideology helps in creating web applications in a completely eccentric way.

Ruby on Rails features

  • MVC architecture: Ruby on Rails is based on the MVC (Model View Controller) architecture that enables the data to be separated from presentation.
  • Customized URL.
  • Debugging.
  • Time Efficient.
  • Localization that helps with integration of your pre designed code into the RoR framework for a bigger project.
  • Libraries. RoR has large libraries to produce high quality product AJAX library, Database access library and Common tasks library. 
  • Speedy software development.
  • Symbol garbage collector.
  • Rails server API.
  • Parallel Testing.
  • Ability to switch  Between Multiple Databases
  • Security (Host Authorization).
  • Easy migration and modification.
  • Diversity of tools and presets.
  • Superior testing environment.
  • Action Mailbox.

Follow this post to show you how to install Ruby on Rails on CentOS 8.

How to Install Ruby on Rails CentOS 8

Install Dependencies

Before starting, you will need to install the EPEL repo to your server. You can install it by running the following command:

					dnf install epel-release -y

Once the EPEL repo is installed, install other required dependencies with the following command:

					dnf install gcc make 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 -y

Once all the dependencies are installed, you can proceed to the next step.

Install Node.js

By default, the latest version of Node.js server is not included in the CentOS default repo. So you will need to add the Node Source repo to your server.

Run the following command to add the Node Source repo:

					curl -sL | bash -

Next, install the Node.js with the following command:

					dnf install nodejs -y

Once the Node.js is installed, verify the Node.js version with the following command:

					node -v

You will get the Node.js version in the following output:


Install Yarn

Next, add the Yarn repo using the following command:

					curl -sL | tee /etc/yum.repos.d/yarn.repo

Next, install the Yarn package with the following command:

					dnf install yarn -y

Install Ruby with Rbenv

Rbenv is a lightweight tool that provides an easy way to install and manage the versions of Ruby. Run the following command to install rbenv into your home directory and set appropriate environment variables.

					git clone ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

					git clone ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL


Next, verify the Rbenv installation using the following command:

					rbenv -v

You will get the following output:

					rbenv 1.2.0-14-gc6cc0a1

To list all available Ruby versions, run the following command:

					rbenv install -l

You will get a list of all Ruby versions in the following output:


Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.


To install the latest Ruby version, run the following command:

					rbenv install 3.1.2

To set the Ruby as the default version for all shells, run the following command:

					rbenv global 3.1.2

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

					ruby -v

To install the bundler, run the following command:

					gem install bundler

Install Ruby Using RVM

RVM is a Ruby Version Manager used to install and manage ruby versions independently by automatically downloading its dependencies.

First, install the RVM with the following command:

					curl -sSL | bash

You will get the following output:

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/`
    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:


Activate the RVM environment variable using the following command:

					source /etc/profile.d/

Verify the RVM version using the following command:

					rvm -v

You will get the following output:

					rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin []

To install the latest Ruby version, run the following command:

					rvm install 3.1.2

You should get the following output:

					Installed rubygems 3.3.7 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-3.1.2 - #gemset created /usr/local/rvm/gems/ruby-3.1.2@global
ruby-3.1.2 - #importing gemset /usr/local/rvm/gemsets/global.gems................................................................
ruby-3.1.2 - #generating global wrappers........
ruby-3.1.2 - #gemset created /usr/local/rvm/gems/ruby-3.1.2
ruby-3.1.2 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-3.1.2 - #generating default wrappers........
ruby-3.1.2 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-3.1.2 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri


Now, set the Ruby version 3.1.2 as the default version using the following command:

					rvm use 3.1.2 --default

To verify the Ruby version, run the following command:

					ruby -v

You will get the Ruby version in the following output:

					ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

Install Rails on CentOS 8

You can install the Rails using the gem command as shown below:

					gem install rails

Once Rails is installed, you can verify it using the following command:

					rails -v

You will get the following output:


Create a Rails Application

At this point, Ruby on Rails is installed on your server. Now, let’s create a simple application to test the Ruby on Rails.

First, install the MySQL server package with the following command:

					dnf install mysql-server mysql-devel -y

Next, start and enable the MySQL service using the following command:

					systemctl start mysqld
systemctl enable mysqld

Next, create an application named sampleapp using the MySQL database:

					rails new sampleapp -d mysql

Please change the directory to sampleapp and edit the database configuration file:

					cd sampleapp
nano config/database.yml

Define your MySQL root password as shown below:

					default: &default
  adapter: mysql2
  encoding: utf8mb4
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password: password
  socket: /var/lib/mysql/mysql.sock


Next, create a database using the following command:

					rake db:create

Then start the server using the following command:

					rails server -b

Once the server is started, you will get the following output:

					=> Booting Puma
=> Rails application starting in development 
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.4 (ruby 3.1.2-p20) ("Birdie's Version")
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 43515
* Listening on
Use Ctrl-C to stop


Now, open your web browser and access your Rails application using the URL http://your-server-ip:3000. You should see your Rails app in the following screen:

How to Install Ruby on Rails CentOS 8 Conclusion

There is a variety of programming languages, frameworks and development platforms to compare. RoR is the top contender as it is multi capable and versatile. 

In this post, we explained how to install Ruby on Rails using different ways. We also create a test application with MySQL database using Ruby on Rails. I hope this will help you to use Ruby on Rails in the development environment.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x