Ruby is a dynamic, interpreted, reflective, object-oriented, general-purpose programming language. According to the creator, Ruby was influenced by Perl, Smalltalk, Eiffel, Ada, and Lisp. It supports multiple programming paradigms, including functional, object-oriented, and imperative. It also has a dynamic type system and automatic memory management.
In this guide, we will explain how to install Ruby on an Ubuntu 16.04/18.04 server.
We will be using two methods of installing Ruby on Ubuntu 18.04:
- Install Ruby on Ubuntu 18.04 from the Brightbox PPA repository.
- Install Ruby using RVM
Install Ruby from Brightbox PPA repository:
Issue the command below to add the Brightbox PPA to your Ubuntu system.
sudo apt -y install software-properties-common sudo apt-add-repository ppa:brightbox/ruby-ng
Next, update your packages list using the command below:
sudo apt update
Next, install the specific version of Ruby you want. Among the versions supported by the Brightbox PPA are the following versions: Ruby 2.6, 2.5, 2.4, 2.3, 2.2, 2.1, 2.0 1.9.3 and 1.8.
For Ruby 2.5
sudo apt install ruby2.5
For Ruby 2.4
sudo apt install ruby2.4
After installation, issue the command below to check the version:
Install Ruby using RVM:
Ruby Version Manager (RVM) is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. First, we need to install the RVM GPG keys using the command below:
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Note: You need to have the GNU Privacy Guard 'gnupg2' package installed before using the above command. If absent, install using
sudo apt-get install gnupg2
Next, install RVM by issuing the command below:
curl -sSL https://get.rvm.io | bash -s stable
Next, issue the command below:
To view the version of RVM installed, issue the command below:
Next, install dependencies by issuing the command:
rvm requirements run
To list available Ruby interpreters, issue the command below:
rvm list known
To install a specific version, issue the command like below:
rvm install 2.5.3