How to Install Ruby on Rails on Ubuntu 16.04

r00t April 22, 2018

Install Ruby on Rails on Ubuntu 16.04

In this tutorial we’ll learn how to install Ruby on Rails on Ubuntu 16.04. We will also install and configure its prerequisites. Ruby on Rails is one of the most popular application stacks for developers who looking to create web apps with Ruby language. Using Ruby language combined with the Rails framework has been simplified the app development.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Ruby on Rails on Ubuntu 16.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

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

Step 2. Installing Ruby Version Manager.

Firstly request a key to verify the legitimacy of the RVM release we will be downloading, which is signed with the matching private key:

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

Now use following command to get a list of available ruby versions:

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

Install Ruby Version:

rvm install 2.3.0

Step 3. Installing Rails.

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

Step 4. 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

To do the same for Rails, use the command:

rails -v

 

Step 5. 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 firstproject

Congratulation’s! You have successfully install and configure Ruby on Rails on your Ubuntu 16.04 server. Thanks for using this tutorial for installing Ruby on Rails on Ubuntu system.

The Tags:

Leave a Comment

Comments are closed.