In this tutorial we will learn about,How to easily install ruby 2.1.0 in CentOS and RHEL.Ruby is a dynamic,open source programming language.At the time of writing this post,ruby version 2.1.0 is available.For installing the ruby version in CentOS and RHEL linux system,we will use RVM method.
What is RVM
RVM stands for 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. (Reference: http://rvm.io/)
To install ruby in Linux system,follow the given below steps
Step 1: Install the latest stable RVM.It is a script which helps you to install required packages.
Note: There is a regular progress in RVM script.The RVM script may undergo with some changes.
curl -L get.rvm.io | bash -s stable
Step 2: Setup the RVM environment. With the above first step 1,we will get the rvm.sh script which helps to setup the RVM environment. This will be mentioned in output from first command which we have done in Step 1.
At the time of writing,the rvm.sh is located in /etc/profile.d/rvm.sh
source /etc/profile.d/rvm.sh
Now check where rvm command is installed.Use which
command.
Below given command is reference
[root@localhost ~]# which rvm /usr/local/rvm/bin/rvm [root@localhost ~]#
Step 3: Install the requirements or dependency.The rvm
command also help you to install requirements automatically.Just run the below given command
rvm requirements
Below given is reference from our system.You can see the dependency packages which are installed automatically.
[root@localhost ~]# rvm requirements Checking requirements for centos. Installing requirements for centos. Updating system. Installing required packages: patch, gcc-c++, patch, readline-devel, zlib-devel, libyaml-devel, libffi-devel, openssl-devel, autoconf, automake, libtool, bison............................ Requirements installation successful. [root@localhost ~]#
Step 4: Now install ruby version 2.1.0 .Likewise you can also install other version.As per post,we are installing ruby 2.1.0 only
rvm install 2.1.0
Below given is the reference from our system.
[root@localhost ~]# rvm install 2.1.0 Searching for binary rubies, this might take some time. No binary rubies available for: centos/6/x86_64/ruby-2.1.0. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for centos. Requirements installation successful. Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.1.0, this may take a while depending on your cpu(s)... ruby-2.1.0 - #downloading ruby-2.1.0, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11.4M 100 11.4M 0 0 376k 0 0:00:31 0:00:31 --:--:-- 459k ruby-2.1.0 - #extracting ruby-2.1.0 to /usr/local/rvm/src/ruby-2.1.0. ruby-2.1.0 - #applying patch /usr/local/rvm/patches/ruby/2.1.0/changeset_r44327.diff. ruby-2.1.0 - #applying patch /usr/local/rvm/patches/ruby/2.1.0/GH-488.patch. ruby-2.1.0 - #configuring.................................................... ruby-2.1.0 - #post-configuration. ruby-2.1.0 - #compiling.................................................................................. ruby-2.1.0 - #installing................................ ruby-2.1.0 - #making binaries executable. ruby-2.1.0 - #downloading rubygems-2.2.1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 401k 100 401k 0 0 74137 0 0:00:05 0:00:05 --:--:-- 1084k No checksum for downloaded archive, recording checksum in user configuration. ruby-2.1.0 - #extracting rubygems-2.2.1. ruby-2.1.0 - #removing old rubygems. ruby-2.1.0 - #installing rubygems-2.2.1............ ruby-2.1.0 - #gemset created /usr/local/rvm/gems/ruby-2.1.0@global ruby-2.1.0 - #importing gemset /usr/local/rvm/gemsets/global.gems..... ruby-2.1.0 - #generating global wrappers. ruby-2.1.0 - #gemset created /usr/local/rvm/gems/ruby-2.1.0 ruby-2.1.0 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list ruby-2.1.0 - #generating default wrappers. ruby-2.1.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-2.1.0 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri [root@localhost ~]#
Step 5: Make the newly installed ruby version 2.1.0 as a default ruby to be used in system.
rvm use 2.1.0 --default
Below is the refrence from our system,As per output,we can see which path of ruby version 2.1.0,it is using(i.e /usr/local/rvm/gems/ruby-2.1.0 )
[root@localhost ~]# rvm use 2.1.0 --default Using /usr/local/rvm/gems/ruby-2.1.0 [root@localhost ~]#
Step 6: Now check the ruby version which is installed.By using command –
ruby -v
See the output given below
[root@localhost ~]# ruby -v ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux] [root@localhost ~]#