How to Install Ruby on Rails on Ubuntu

How to Install Ruby on Rails on Ubuntu

Because of  many codes running on a Linux server and Ubuntu is one of the easiest Linux distributions to use, it is also able to get Rails up and running locally. Those advantages has made Ubuntu as an operating system to develop Rails.  

For those who want to install Ruby on Ubuntu, we have made the simple guide for you.

1. Use Ubuntu with a non-root user

If you still have the outdated version of Ubuntu, we advice you to upgrade to Ubuntu 16.04 version with a non-root user.  
Foremost, you need to update your package manager using this command:

$ sudo apt-get update

Then install Curl for installing RVM using this command:

$ sudo apt-get install curl

2. Install RVM and Ruby

We previously wrote an article about how to install Ruby on Rails on Mac, and we added the procedure to install RVM. However, using Ubuntu as the operating system will take a different way. Simply use this command below:

$ curl –L | bash –s stable –ruby

The backlash before curl intends to avoid potential version conflicts as “—ruby” is used to automatically install the latest version of Ruby.

Note that if you have already installed RVM, you need to upgrade it into the latest version first before you install Ruby. Use this command to complete this task:

$ rvm get stable –autolibs=enable

$ rvm install ruby

$ rvm –default use ruby-2.3.1

3. Install Node.js

You need to install Node.js because some of Rails features, including Assest Pipeline, need it in order to function properly. Use this command:

$ sudo apt-get install nodejs

4. Check the Gem Manager

Stay current of your RubyGem by always visiting If you want to check your version of RubyGem, simply type:

$ gem -v

5. Install Bundler

Bundler purposes for managing gems when you run and develop Rails. If you follow this step and previously has installed RVM, usually Bundler gem would be installed automatically. However, starting to Bundler version 1.26.11, RVM is no loonger install Bundler naturally. Thus, you must install Bundler using this command:

$ gem install bundler

6. Install Rails

In order to install the most current Rails into the global gemset, follow this command:

$ rvm use [email protected] –create

There are many options to install Rails for you to choose. If you want the newest stable release:

$ gem install rails

$ rails -v

Or if you prefer the specific version or Rails:

$ gem install rails –version=(type the specific version you want to install)

$ rails -v  

Your choice!

7. Create New Rails Application

Now it’s time to make a project-specific gemset, install Rails, and create a new application. Simply use this command below:

$ mkdir myapp

$ cd myapp

$ rvm use [email protected] –ruby-version –create

$ gem install rails

$ rails new .


We hope this guidance will help you install Ruby on Rails on Ubuntu. If you have any additional question or require further clarification, please do not hesitate to drop a comment in the comment section below!


Scroll to Top
%d bloggers like this: