LinuxTutorialsUbuntu

How To Install Ruby on Rails on Ubuntu 16.04

Install Ruby on Rails on Ubuntu 16.04

In this tutorial, we will show you how to install and configuration of Ruby on Rails on your Ubuntu 16.04 server. For those of you who didn’t know, Ruby on Rails (RoR) is a framework written in the Ruby programming language that allows you to use Ruby in combination with HTML, CSS, and similar programming languages. It is used by many developers since it makes application development very simple.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Ruby on Rails on a Ubuntu 16.04 (Xenial Xerus) server.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 16.04 (Xenial Xerus).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Ruby on Rails on Ubuntu 16.04

Step 1. First, make sure that all your system packages are up-to-date by running the following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Installing RVM.

One way of installing Ruby on Rails on a VPS is by using the Ruby enVironment 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

To start using RVM you need to run:

source /usr/local/rvm/scripts/rvm

If, for some reason, you need or want a different version of Ruby, you can check which ones are available easily in RVM:

rvm list known

The list result should look like the following one:

# 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
...

To install a different version of Ruby, just find the version number that you want and tell RVM to install it:

rvm install 2.3.0
rvm use 2.3.0

Step 3. Installing Rails.

Now that RVM is installed and configured and Ruby is on the system, you can install Rails. Rails is available as a Gem, which is a Ruby package. When Ruby is installed, its native Gem packaging system is also installed. Installing Ruby packages is very similar to any Linux package manager. To install Rails you can use the command below:

gem install rails

Or, run the following command to install a particular version of rails:

gem install rails -v 5.0.0

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

rails -v

Sample output:

# rails -v
Rails 5.0.0.1

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 idrootApp

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.

Congratulations! You have successfully installed Ruby on Rails. Thanks for using this tutorial for installing Ruby on Rails in Ubuntu 16.04 (Xenial Xerus) systems. For additional help or useful information, we recommend you to check the official Ruby on Rails website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save

Save

Save

Save

Save

Save

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button