Ruby on Rails on Ubuntu

[2 min installs] Ruby on Rails on Ubuntu

Better Stack Team
Updated on August 30, 2022

Here is how to install Ruby on Rail in under two minutes:

Step 1 - Install dependencies

Before installing Ruby on Rails, you need to install its dependencies first.

  1. Update package list on your system:
sudo apt-get update -y
  1. Install build-essentials
sudo apt-get install build-essential
  1. Install the developer dependencies.
sudo apt-get install libssl-dev zlib1g-dev sqlite3 libsqlite3-dev
  1. Install Git and curl if not already installed.
sudo apt-get install git curl

Step 2 - Install Nodejs & Yarn

Rails use the JavaScript runtime through Node.js to build the applications.

  1. Install the latest Node.js version (if not already installed)
curl -fsSL | sudo -E bash -
sudo apt-get install nodejs
  1. Install Yarn
curl -fsSL | 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 yarn

Step 3 - Install rbenv

rbenv is a Ruby version manager used to install and manage Ruby environments.

  1. Install rbenv
curl -fsSL | bash
  1. Add rbenv to the path
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
exec $SHELL

Step 4 - Install Ruby

Now it is time to install the latest stable version of Ruby language. If you have done this already, you can skip this step.

  1. List the latest Ruby versions
rbenv install -l
  1. Install the desired version (rails require version 2.5.0 or newer)
rbenv install 3.0.2 -v
  1. Set global Ruby version
rbenv global 3.0.2
  1. Install ruby bundler using gem
gem install bundler

Step 5 - Install Rails

Finally, install rails using the following command:

gem install rails

That’s it

You have installed Ruby on Rails on your system. To test if everything worked, create a test project and run it:

rails new hello-world
cd hello-world
rails server --binding=
Check Uptime, Ping, Ports, SSL and more.
Get Slack, SMS and phone incident alerts.
Easy on-call duty scheduling.
Create free status page on your domain.
Got an article suggestion? Let us know
Next article
[2 min installs] Nginx on Ubuntu
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.