Objective

The objective is to install Ruby on Rails on Ubuntu 18.04 Bionic Beaver Linux. First we will perform a standard installation from Ubuntu 18.04 repositories. The second part of this tutorial will show you how to use Ruby Version Manager (RVM) to install the latest Ruby.

Operating System and Software Versions

  • Operating System: - Ubuntu 18.04 Bionic Beaver Linux

Requirements

Privileged access to your Ubuntu 18.04 Bionic Beaver is required to install Ruby on Rails on Ubuntu 18.04 and/or prerequisites.

Difficulty

EASY

Conventions

  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - requires given linux commands to be executed as a regular non-privileged user

Installation from Ubuntu Repositories

Ruby on Rails installation from Ubuntu Repositories is most likely the simplest way on how to accomplish this task. The disadvantage is that you are most likely to end up with outdated but stable version. Execute the following linux command to install ruby on rails:
$ sudo apt install ruby rails
Check versions:
$ ruby -v
ruby 2.3.6p384 (2017-12-14) [x86_64-linux-gnu]
$ rails -v
Rails 4.2.9
All done. Next, create a new sample project to test your Ruby on Rails installation. Example:
$ rails new linuxconfig
$ cd linuxconfig/
Start the rails WEBrick server:
$ rails s -b 0.0.0.0
To see the front page of your new sample project, navigate your browser to http://YOUR-SERVER-IP:3000.

Ruby on Rails on Ubuntu 18.04 Bionic Beaver Linux - repository

$$$ Looking for LINUX ADMINISTRATOR ! $$$

BLUE SKY STUDIOS are looking for Linux Administrator to maintain and support the Studio's 450+ production Linux workstations, including daily interactions with the Studio’s digital animation artists.
LOCATION: Greenwich, Connecticut, USA

APPLY NOW

Installation using Ruby Version Manager

The following procedure will show you how to install Ruby on Rails on Ubuntu 18.04 using RVM. Let's start by installation of all prerequisites:
$ sudo apt install nodejs curl
Next, import the signing key to be able to verify the RVM packages downloaded in the later step:
$ curl -sSL https://rvm.io/mpapis.asc | gpg --import -
gpg: /home/linuxconfig/.gnupg/trustdb.gpg: trustdb created
gpg: key 3804BB82D39DC0E3: public key "Michal Papis (RVM signing) " imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no ultimately trusted keys found
Lastly, install Ruby Version Manager along with a stable ruby version:
$ curl -sSL https://get.rvm.io | bash -s stable --ruby
Update you shell environment to be able to access ruby:
$ source /home/linuxconfig/.rvm/scripts/rvm
Once ready, install Rails gem:
$ gem install rails
Alternatively, install any other rails version. For example to install rails version 4.4 run:
$ gem install rails -v 4.4
Confirm installed Ruby on Rails versions:
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
$ rails -v
Rails 5.1.4
The advantage of installation of Ruby on Rails using Ruby Version Manager over a standard Ubuntu repository is that it allows the user to list all available ruby versions $ rvm list known, install any version available e.g $ rvm install 2.4, select between any installed version $ rvm use 2.4 and set any installed version as default $ rvm use 2.4 --default.



Lastly, we test our installation by creating a sample Ruby on Rails project:
$ rails new linuxconfig
$ cd linuxconfig/
Start the rails WEBrick server:
$ rails s -b 0.0.0.0
To see the front page of you new sample project, navigate your browser to http://YOUR-SERVER-IP:3000.

Ruby on Rails on Ubuntu 18.04 Bionic Beaver Linux - Ruby Version Manager
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: