Install Ruby on Rails on Ubuntu / CentOS / Fedora using RVM

Ruby Logo
Ruby Logo

Ruby is an open-source programming language, more popular these days. Ruby language was designed and developed by Yukihiro “Matz” Matsumoto in mid 1995. This article will help you to install Ruby on Rails on Ubuntu 14.10, 14.04 LTS / CentOS 7 / RHEL 7 / Fedora 22 / Fedora 21 using RVM. RVM provides an easy set of commands to install single or multiple versions of Ruby on single server.

Table of contents:

1. Install RVM

2. Install Rails

3. Install Node.js

4. Install MySQL Database

5. Create a Test Application

Install RVM:

RVM stands for Ruby Version Manager. It provides efficient way to install and manage ruby version independently. This command will automatically download all required files and install on your system, we will just use it to install the latest version of Ruby on your system.

Install curl:

If your machine do not have curl installed, you can start installing it.

### Ubuntu / LinuxMint ###

$ sudo apt-get install curl gnupg2

### CentOS / Fedora ###

# yum install curl

Install RVM:

Before installing RVM on your system, import public key in your system and then use curl to install RVM in your system.

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable

After installing RVM, we need to load rvm environment variable using below command.

source /etc/profile.d/rvm.sh

Install all the dependencies for installing ruby on the system using below command.

rvm requirements

Run following command to get a list of available ruby versions, that can be installed on system.

# 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[-p643]
[ruby-]2.1.4
[ruby-]2.1[.5]
[ruby-]2.2[.1]
[ruby-]2.2-head
ruby-head

With RVM, we can manage multiple ruby versions on single system. Use following command to install Ruby 2.2.2. You can also install multiple versions of ruby using rvm command with version.

rvm install 2.2.2

Run following command to set version 2.2.2 as default version of ruby.

# rvm use 2.2.2 --default
Using /usr/local/rvm/gems/ruby-2.2.2

Check the current ruby version is used.

# ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]

Install Rails:

We can install latest stable release of Rails by running following command. This process may take a while, be patient with it. Once it finishes you will have Ruby on Rails installed on your system.

gem install rails
rails -v

You can also install specific version of rails by using following command.

gem install rails --version=4.2.3

Once you have installed Ruby on Rails on Ubuntu, we can create a test application to test it out. To do that, follow below steps.

Install Node.js

Install MySQL Database

Create a Test Application

That’s All!!!, you have successfully installed Ruby on Rails on Ubuntu / CentOS using RVM.

POSTS YOU MAY LIKE -:)

Share This Post

  • Lazio

    Got this error when trying to install rvm and now I’m stuck

    comsol@ubuntu:~$ gpg2 –keyserver hkp://keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

    gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net

    gpgkeys: HTTP fetch error 7: Failed to connect to keys.gnupg.net port 11371: Connection refused

    gpg: no valid OpenPGP data found.

    gpg: Total number processed: 0

    comsol@ubuntu:~$ curl -sSL https://get.rvm.io | bash -s stable

    Downloading https://github.com/rvm/rvm/archive/1.26.11.tar.gz

    Downloading https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc

    gpg: Signature made Mon 30 Mar 2015 02:52:13 PM PDT using RSA key ID BF04FF17

    gpg: Can’t check signature: No public key

    Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found.

    Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).

    GPG signature verification failed for ‘/home/comsol/.rvm/archives/rvm-1.26.11.tgz’ – ‘https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc’!

    try downloading the signatures:

    gpg2 –keyserver hkp://keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

    or if it fails:

    command curl -sSL https://rvm.io/mpapis.asc | gpg2 –import –

    the key can be compared with:

    https://rvm.io/mpapis.asc

    https://keybase.io/mpapis

    comsol@ubuntu:~$

    • From this error,

      gpgkeys: HTTP fetch error 7: Failed to connect to keys.gnupg.net port 11371: Connection refused

      Look like some issue in connecting to destination server.
      Please check the internet connectivity

      • Lazio

        Many thanks for your response. I later got that fixed. The keyserver signature

        “gpg2 –keyserver hkp://keys.gnupg.net –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3”

        was blocked by some firmware

        I later used this command “curl -sSL https://rvm.io/mpapis.asc | gpg2 –import -”

        suggested from the error message and that fixed it

Shares