How to install Ruby on Rails on Ubuntu 20.04?
Overview
In this tutorial we will be installing Ruby, Gems, and, Rails which is an open-source framework written in Ruby that is why it is called Ruby on Rails. We will be using rbenv to install them, rbenv is a version manager tool for the Ruby programming language on Unix-like systems.
Prerequisites
There are certain prerequisites that need to be met before you begin.
An Ubuntu 20.04 machine
Knowledge of CLI
A user with root access
Get Started
Step 1 - Installing Dependencies and rbenv
i. Update your packages using the below command:
ii. Install dependencies necessary for Ruby installation.
iii. Install rbenv using the following command:
iv. To utilise the rbenv command line tool, add /.rbenv/bin to your $PATH environment variable.
v. To make rbenv load automatically, add the command eval "$(rbenv init -)" to your /.bashrc file:
vi. In your current shell session in your ~/.bashrc
file, implement changes made, click apply:
vii. Verify that rbenv is set up by using the following command:
Step 2 - Install Ruby using ruby build
i. List the various Ruby versions first.:
ii. Now, let’s install latest version of Ruby:
iii. By using global sub-command, make it the standard version of Ruby.:
iv. Check Ruby's version number to ensure that it was installed correctly:
Step 3 - Installing Gems
i. Gems are distributed Ruby libraries. Gem commands are also used to install Ruby.
ii. Install Bundler to manage gem dependencies for your Ruby projects.
iii. To confirm the path where gem has been installed, type the following command:
Step 4 - Installing Rails
i. Install Rails using the following command:
ii. Run the following command, whenever installing a new version of Ruby:
iii. Verify that Rails has been installed properly by checking its version, with the following command:
Conclusion
In this tutorial, we installed and configured the entire Ruby and Rails framework using rbenv and gem. Now you may start working on your Ruby framework projects.
Last updated