How to Install Ruby on Rails Ubuntu 20.04 Tutorial (Step by Step)

How to Install Ruby on Rails Ubuntu 20.04. In this tutorial we will introduce Ruby on Rails (ROR) with it’s main features and move onto installation phase with Node.js and Yarn install. There is 2 way installation tutorial of ROR: Ruby using rbenv and with RVM.


Ruby on Rails is one of the most popular server side and e commerce web development framework. Ruby on Rails framework is a highly stable and powerful platform for building an E-commerce website.

What Is Ruby On Rails

Ruby on Rails (ROR) or Rails is an open source web application development framework, which is created using a general purpose programming language, Ruby. It runs on Linux and ROR is a dynamic fully object oriented and scripting language. It constitutes a collective code library, delivering both apps and web developers convenient solutions to eliminate time consuming and redundant tasks.

Ruby on Rails server helps you to find code for basic functions instead of writing every single code in a program afresh. She further added that while other frameworks naturally make the development of a complex website manageable, Ruby on Rails is known for its effortless maintenance and lending itself out to collaboration.

Moreover, the two primary principles of Ruby are:

  • Don’t Repeat Yourself (DRY) – It is a principle of software development stating that every piece of knowledge must have a single, unambiguous and authoritative representation within a system. It eliminates the need for writing the same information consistently, making it more manageable, extensible and less buggy.
  • Convention Over Configuration – Rails is a multi purpose web application development framework and has this set of conventions by default. 

Benefits of Ruby On Rails

Ruby on Rails provides you with the benefits that are as given below:

Cost Effective

Ruby on Rails is an open source framework that is 100 percent free and is capable of running on Linux. Developers find this framework quite efficient to work with. It provides you with numerous plugins that help you save time and makes the development and management more straightforward. 

Faster Development

ROR contains many ready made plugins and modules where developers and teams can build applications 30–40% faster than teams using other programming languages and frameworks.

Easy Code Maintenance and Updates

Web developers highly rely on Ruby on Rails because of its stability and predictability. It makes the process of modifying existing code and adding new features to the site relatively effortless. Whether you want to update an application or refract its code, it provides a convention that allows you to do so immediately.

Build On Model View Controller (MVC) Architecture

In this architecture, the web application has three interconnected layers. The model contains codes that run on application data. Centralize application business logic and data processing rules. The controller communicates with models and views. It receives a request from the browser, works with the model to process it and instructs the user how to display the result correctly.

Quality Product

Not only did RoR save your time and money but also helps in providing a high quality product. It is susceptible to fewer risks and can build the website, following the principles of good development more effectively. It is all because of its high quality libraries. This way you focus on exploring your business needs and creating a better product. It also promotes testing automation that assists you in delivering better software.

Manages Changes Effortlessly

With Ruby on Rails tools  you can easily modify the existing codes or add new features to your site. It is the most effective frameworks if you are working on long term projects as they are highly stable and predictable.


The framework has in built security measures, meaning that they follow the secure development lifecycle that actively works to spot and patch vulnerabilities. This makes the framework well documented both officially and unofficially. Hence, you don’t have to worry about your site’s security.

Suitable for all business industries

Ruby on Rails is a full stack framework that covers both front and back end design. RoR is well suited in advertising, mobile apps, e-commerce, machine learning, tech world, social platforms and science. 

Follow this post below to show you how to install Ruby on Rails on Ubuntu 20.04.

Install Ruby on Rails Ubuntu 20.04

Install Required Dependencies

Before starting, you will need to install some dependencies in your server. You can install all of them by running the following command:

					apt-get install curl gnupg2 dirmngr git-core libcurl4-openssl-dev software-properties-common zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libffi-dev -y

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

Install Node.js and Yarn

Next, you will need to install Node.js server and Yarn package to your server. By default, the latest version of Node.js is not available in the Ubuntu 20.04 default repository. So you will need to add the Node source repository to APT. You can add it using the following command:

					curl -sL | bash -

Once the repository is added, you can install the Node.js by running the following command:

					apt-get install nodejs -y

Next, verify the Node.js version with the following command:

					node -v

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


Please add the Yarn repository with the following command:

					curl -sL | apt-key add -
echo "deb stable main" | tee /etc/apt/sources.list.d/yarn.list

Once the repository is added, update it and install the Yarn package with the following command:

					apt-get update -y
apt-get install yarn -y

Install Ruby on Ubuntu

There are two ways you can install Ruby on Ubuntu 20.04.

  1. Install Ruby using rbenv
  2. Install Ruby using RVM

Let’s explore each method one by one.

Install Ruby with rbenv

The rbenv allows you to install and manage multiple versions of Ruby easily. First, download the rbenv source from the Git repository:

					git clone ~/.rbenv

Next, export the rbenv path with the following command:

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

Next, download the ruby-build from the Git repository:

					git clone ~/.rbenv/plugins/ruby-build

Next, add the Ruby-build path with the following command:

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


Next, install the latest version of Ruby by running the following command:

					rbenv install 3.1.0

You will get the following output:

					Downloading ruby-3.1.0.tar.gz...
Installing ruby-3.1.0...
Installed ruby-3.1.0 to /root/.rbenv/versions/3.1.0

To set the Ruby version 3.1.0 as a default version, run the following command:

					rbenv global 3.1.0

You can now verify the Ruby version with the following command:

					ruby -v

You should see the following output:

					ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]

To install bundler package, run the following command:

					gem install bundler

Install Ruby with RVM

RVM (Ruby Version Manager) allows you to install and manage Ruby versions independently by automatically downloading its dependencies.

First, add the GPG key with the following command:

					gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL | gpg2 --import -

Next, install the RVM using the following command:

					curl -sSL | bash -s stable

Please activate the RVM environment variable using the following command:

					source /etc/profile.d/

Next, run the following command to install Ruby version 3.0.3:

					rvm install 3.0.3

Please set the Ruby version 3.0.3 as a default version using the following command:

					rvm use 3.0.3 --default

To verify the Ruby version, run the following command:

					ruby -v

You should see the following output:

					ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]

Install Rails

You can use the gem command line utility to install the latest version of Rails as shown below:

					gem install rails

To verify the Rails version, run the following command:

					rails -v



Create a Rails Application

In this section, we will create a simple Rails application to check the Ruby on Rails installation.

Let’s create a simple application named myapp with the following command:

					rails new myapp

You can see all files and directories created by the above command using the following command:

					cd myapp


					app bin config db Gemfile Gemfile.lock lib log public Rakefile storage test tmp vendor

Now, start the Rails application using the following command:

					rails server -b

Once the application 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.0.3-p157) ("Birdie's Version")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 29540
* Listening on
Use Ctrl-C to stop

Access Ruby on Rails app

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

Install Ruby on Rails Ubuntu 20.04 Conclusion

In this article, we explained how to install Ruby on Rails on Ubuntu 20.04 server using two different methods. We also explained how to create a simple Rails application. You can now start developing your own Rails application.

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.

2 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x