Skip to content

Instantly share code, notes, and snippets.

@nelsonmfinda
Last active August 12, 2020 08:40
Show Gist options
  • Select an option

  • Save nelsonmfinda/b8ba30a3ccc9ee16268e45d9f805d145 to your computer and use it in GitHub Desktop.

Select an option

Save nelsonmfinda/b8ba30a3ccc9ee16268e45d9f805d145 to your computer and use it in GitHub Desktop.
Setup Ruby and Ruby on Rails on Ubuntu 19.04

Ruby on Rails(RoR) is a web framework written in the Ruby programming language, designed to develop successful projects while writing less code.

The command-line tool RVM (Ruby Version Manager) which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

Prerequisites

  • Ubuntu 19.04 x64 server instance

  • we need to install software-properties-common :

    sudo apt-get install software-properties-common

Installation

Run the following command to add the RVM key to your system, this key allows us to verify the legitimacy of the RVM release we will be downloading, which is signed with the matching private key:

gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Install and Configure RVM

Let’s now move into a writable location such as the /tmp directory:

cd /tmp

Now run the following command to install the latest stable version of RVM:

curl -sSL https://get.rvm.io | bash -s stable

When the installation is complete, source the RVM scripts from the directory they were installed, which will typically be in your /usr/local/rvm/ directory:

source /usr/local/rvm/scripts/rvm

Now the source for RVM is set. You can check the version number of RVM installed on your system:

rvm --version

Install the latest version of Ruby and Ruby on Rails on your system, First, check to see which version of Ruby are available:

rvm list known

Through this list, install the specific version of Ruby that you need through RVM

Note: In this article, I have installed Ruby 2.6.3 version, you can install a specific Ruby version you need through RVM.

rvm install 2.6.3

After the installation, list available Ruby version we have installed:

rvm list

Run the following RVM command will help you in setting the latest installed version of Ruby as the system default:

rvm use --default 2.6.3

Install Ruby on Rails

Next, we can install the latest version of Bundler :

gem install bundler

After that, list available versions of Rails:

gem search '^rails$' --all

Note: this RoR version will only refer to the version number.

Now, install Ruby on Rails need version:

gem install rails -v 5.2.3

Install JavaScript Runtime

We need to install some dependencies of RoR, It is a prerequisite for compiling Ruby on Rails asset pipeline:

cd /tmp
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -o install_nodejs.sh

Verify the Node script by outputting it to a file, then read it with less:

less install_nodejs.sh

If you're satisfied with the Node script, install the Node source Node.js v12.x repo:

cat /tmp/install_nodejs.sh | sudo -E bash -

Next, update apt, and install Node:

sudo apt update
sudo apt install -y nodejs

Install the Yarn package manager:

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
     echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment