Installing Ruby on Rails on Ubuntu 20.04 Step by Step Tutorial

Installing Ruby on Rails on Ubuntu 20.04 Step by Step Tutorial

In this article, we will learn how to configure Ruby on Rails on Ubuntu 20.04 server Focal Fossa. We will install Ruby 2.7 with RVM, rbenv, and using the source. Now without wasting any more time let’s begin with this tutorial.

Before we start installing Ruby on Rails on the server, we need to install all the dependencies. We need to install Yarn and Nodejs repositories on the server. Execute the following set of commands on the server.

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

sudo apt-get update
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn


Installing Ruby on Rails using RVM on Ubuntu 20.04

Installing Ruby on Rails on the Ubuntu 20.04 with RVM is quite simple, just execute the following commands, step by step on the terminal.

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.7.1
rvm use 2.7.1 --default
ruby -v

PS: If you want to install any other version of Ruby, simply change the version number, while using RVM install command. For Example, for Ruby 2.6 version use this command.

rvm install 2.6
rvm use 2.6 --default


Installing Ruby using rbenv on ubuntu 20.04
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

rbenv install 2.7.1
rbenv global 2.7.1
ruby -v


Installing Ruby on Rails using the Source
tar -xzvf ruby-2.7.1.tar.gz
cd ruby-2.7.1/
sudo make install
ruby -v


The next step is to install Bundler

gem install bundler

If you are using the rbenv method, then execute the following command on the terminal.

rbenv rehash

Now let’s move on to the next part.


Installing Rails 6.0 on the Ubuntu server.
gem install rails -v

rbenv users need to use the following command after the Rails installation.

rbenv rehash


If you want to setup LAMP stack on the Ubuntu 20.04 then follow this tutorial.



Leave a Reply

Your email address will not be published. Required fields are marked *