Installing Ruby on Rails on Ubuntu

In this article we will provide basic steps on how to install Ruby on Rails onto Ubuntu based VPS. Ruby on Rails is one of the most popular programming languages nowadays based on GitHub.

Ruby is known among programmers for a terse, uncluttered syntax that doesn’t require a lot of extra punctuation. Compared to Java, Ruby is streamlined, with less code required to create basic structures such as data fields.

Rails is a framework for building websites. As such, Rails establishes conventions for easier collaboration and maintenance.

Preparation

Before you start installing Ruby on Rails, prepare your server for it. Make sure your system is update:

apt-get update && apt-get -y upgrade

Also, you will be required to install Curl at some point, why not at the beginning:

apt-get install curl -y

Installation

After that, you will need to install Ruby Version Manager (RVM), which will help to follow newest available Ruby version and install them quicker:

You will be presented with a list of available versions, like example below:

You can choose one and install as following:

rvm install 2.4.1

Once you install Ruby, you can check the version with the following command:

ruby --version

You will see something like:

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

After Ruby is installed, you may as well proceed with Rails installation:

gem install rails

You can check Rails version at any time as well:

rails -v

Results should be as following:

Rails 5.1.4

That is it. You have installed Ruby on Rails. Now you can start your new Rails application:

Starting a new Ruby on Rails project

We will create a new project-specific gemset. When we create the gemset, it will be empty (though it inherits use of all the gems in the global gemset). However, we will be able to install a more specific version of Ruby if needed. As you may understand RVM allows you to use multiple Ruby version with every new project (gemset). We also install Raills as a framework for specific gemset.