Ruby programming language is becoming is more popular these days. Ruby language was created by Yukihiro “Matz” Matsumoto and first published in 1995. This article will help you to install Ruby language in CentOS, RedHat system using RVM. For this article I am using CentOS 6.5. RVM provides easy set of commands to install single or multiple versions of Ruby on single server.
Step 1: Upgrade Packages
It is the best practice to keep your system up to date with latest packages. Before running below command make sure that update will not affect to your running apps ( if any )on server else skip it
Step 2: Installing Recommended Packages
There are few developemnt libraries required to run Ruby on Linux. Use following command to install recommended packages on your server using yum.
installgcc-c++ patch readline readline-devel zlib zlib-devel # yum installlibyaml-devel libffi-devel openssl-devel make # yum installbzip2 autoconf automake libtool bison iconv-devel
Step 3: Install RVM ( Ruby Version Manager )
Install latest stable version of RVM on your system using following command. This command will automatically download all required files and install on your system.
# curl -L
get.rvm.io| bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 20511 100 20511 0 0 1120 0 0:00:18 0:00:18 --:--:-- 19722 Downloading https://github.com/wayneeseguin/rvm/archive/stable.tar.gz Creating group 'rvm' Installing RVM to /usr/local/rvm/ Installation of RVM in /usr/local/rvm/ is almost complete: * First you need to add all users that will be using rvm to 'rvm' group, and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`. * To start using RVM you need to run `source /etc/profile.d/rvm.sh` in all your open shell windows, in rare cases you need to reopen all shell windows. # Administrator, # # Thank you for using RVM! # We sincerely hope that RVM helps to make your life easier and more enjoyable!!! # # ~Wayne, Michal & team. In case of problems: http://rvm.io/help and https://twitter.com/rvm_io
Step 4: Setup RVM Environment
After installing RVM first we need to setup rvm environment using below command.
Step 5: Install Required Ruby Version
RVM provides option to manage multiple ruby version on single system. Use following command to install required version of Ruby.
# rvm install
Searching for binary rubies, this might take some time. No binary rubies available for: centos/6/i386/ruby-1.9.3-p545. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for centos. Installing requirements for centos. Updating system...... Installing required packages: libyaml-devel...... Requirements installation successful. Installing Ruby from source to: /usr/local/rvm/rubies/ruby-1.9.3-p545, this may take a while depending on your cpu(s)... ruby-1.9.3-p545 - #downloading ruby-1.9.3-p545, 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 9802k 100 9802k 0 0 217k 0 0:00:45 0:00:45 --:--:-- 393k ruby-1.9.3-p545 - #extracting ruby-1.9.3-p545 to /usr/local/rvm/src/ruby-1.9.3-p545. ruby-1.9.3-p545 - #applying patch /usr/local/rvm/patches/ruby/GH-488.patch. ruby-1.9.3-p545 - #applying patch /usr/local/rvm/patches/ruby/ssl_no_ec2m.patch. ruby-1.9.3-p545 - #configuring.............................................. ruby-1.9.3-p545 - #post-configuration. ruby-1.9.3-p545 - #compiling................................................................... ruby-1.9.3-p545 - #installing........................ ruby-1.9.3-p545 - #making binaries executable. ruby-1.9.3-p545 - #downloading rubygems-2.2.2 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 404k 100 404k 0 0 25393 0 0:00:16 0:00:16 --:--:-- 335k No checksum for downloaded archive, recording checksum in user configuration. ruby-1.9.3-p545 - #extracting rubygems-2.2.2. ruby-1.9.3-p545 - #removing old rubygems. ruby-1.9.3-p545 - #installing rubygems-2.2.2............... ruby-1.9.3-p545 - #gemset created /usr/local/rvm/gems/ruby-1.9.3-p545@global ruby-1.9.3-p545 - #importing gemset /usr/local/rvm/gemsets/global.gems..... ruby-1.9.3-p545 - #generating global wrappers. ruby-1.9.3-p545 - #gemset created /usr/local/rvm/gems/ruby-1.9.3-p545 ruby-1.9.3-p545 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list ruby-1.9.3-p545 - #generating default wrappers. ruby-1.9.3-p545 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-1.9.3-p545 - #complete WARNING: Please be aware that you just installed a ruby that is no longer maintained (2014-02-23), for a list of maintained rubies visit: http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering Please consider upgrading to ruby-2.1.1 which will have all of the latest security patches. Ruby was built without documentation, to build it run: rvm docs generate-ri
Step 6: Install Another Version
( if Required )
If you want using multiple versions of ruby, you can install it also using rvm else skip this step.
# rvm install
Step 7: Setup Default Ruby Version
Use rvm command to setup default ruby version to be used by applications.
rvm use 1.9.3 --defaultUsing /usr/local/rvm/gems/ruby-1.9.3-p545
Step 8: Check Current Ruby Version
Using following command you can check the current ruby version is used.
# ruby --versionruby 1.9.3p545 (2014-02-24 revision 45159) [i686-linux]
I hope above steps will help you for installing multiple Ruby version using RVM.