Ruby installation - Linux


Listed below are the steps to install Ruby on a Linux machine.

Note: Before installation, please make sure you have root permissions.


Source code installation

  • Download the latest version of Ruby compressed file. Please click here to download.

  • After downloading Ruby, unzip it to the newly created directory:

$ tar -xvzf ruby-2.2.3.tgz    
$ cd ruby-2.2.3
  • Now, configure and compile the source code , as shown below:

$ ./configure
$ make
$ sudo make install
  • After installation, make sure everything is working properly by entering the following command at the command line:

$ruby -v
ruby 2.2.3……
  • If everything is working fine, the version of the Ruby interpreter installed will be output, as shown above. If you have a different version installed, a different version will be displayed.

Automatically install Ruby

If your computer is connected to the Internet, the easiest way to install Ruby is to use yum or apt-get. Enter the following command in the command prompt to install Ruby on your computer.

$  sudo yum install ruby    # CentOS, Fedora, 或 RHEL 系统

或

sudo apt-get install ruby-full # Debian 或 Ubuntu 系统

If you have an Apple system, you can use the brew command to install:

$ brew install ruby