Install Ruby on Rails on Ubuntu 16.04

Install Ruby on Rails on Ubuntu 16.04

We’ll show you how to Install Ruby on Rails on Ubuntu 16.04. Ruby on Rails is a full stack web application framework which provides default structures for databases, web services and web pages. It is used by many developers since it makes the application development very simple. In this tutorial we will show you how to install Ruby on Rails on a Linux VPS running Ubuntu 16.04 as an operating system.

1. Connect to your server via SSH and update your system

First of all, you need to connect to your server via SSH as root or as a regular system user and update all your system software to the latest version available. For that purpose you can run the following command:

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

2. Install Ruby Version Manager – RVM

One way of installing Ruby on Rails on an Ubuntu VPS is by using the Ruby Version Manager, or shortly RVM. We will use RVM to install Ruby on Rails in this tutorial. In order to install RVM on your server, you can use the following commands:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
cd /tmp && \curl -sSL https://get.rvm.io -o rvm.sh
cat /tmp/rvm.sh | bash -s stable

If you get something like this:

-bash: curl: command not found

3. Install CURL on your server

that means curl is not installed on your server. Go ahead and install curl by using the command below:

apt-get install curl

4. Run RVM

To start using RVM you need to run:

source /usr/local/rvm/scripts/rvm

5.  List which Ruby versions are available for installation

To list which Ruby versions are available for installation, run the following command:

rvm list known

The list should look like the following one:

# rvm list known
# MRI Rubies
[ruby-] 1.8.6 [-p420]
[ruby-] 1.8.7 [-head] # security released on head
[ruby-] 1.9.1 [-p431]
[ruby-] 1.9.2 [-p330]
[ruby-] 1.9.3 [-p551]
[ruby-] 2.0.0 [-p648]
[ruby-] 2.1 [.8]
[ruby-] 2.2 [.4]
[ruby-] 2.3 [.0]
[ruby-] 2.2-head
ruby-head
...

6. Install the version of your choice

To install a specific version of Ruby (for example 2.3.0) you can use the command:

rvm install 2.3.0

Rails is a Ruby gem and different versions of Rails are available for installation too. To install Rails you can use the command below:

gem install rails

7. Verify Ruby on Rails Installation

To verify the installation as well as to check what version of Ruby you are currently using, you can use the command:

ruby --version

The output should be similar to the following one:

# ruby --version
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

To do the same for Rails, use the command:

rails -v

The output should be similar to the following one:

# rails -v
Rails 5.0.0.1

8. Create a new Ruby on Rails application

Now you are ready to start with your first Ruby on Rails project. Create a new Ruby on Rails application in your home directory:

cd ~
rails new firstApp

This should take no longer than a minute. Once your new Ruby on Rails application is created, you can start developing the application. There are new guides for Rails 5.0 which will help you understand how all of the pieces fit together. Good Luck!


Of course you don’t have to Install Ruby on Rails on Ubuntu 16.04,  if you use one of our Ruby on Rails VPS hosting services, in which case you can simply ask our expert Linux admins to install Ruby on Rails on Ubuntu 16.04 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to install Ruby on Rails on Ubuntu 16.04 please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment