RVM, or Ruby Version Manager is a popular and effective way to manage running multiple Ruby environments. Here is how you set it up on CentOS 5.5:
1) Add the Webtatic respository and install Git.
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source .bash_profile
type rvm | head -1
rvm notes
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel yum install -y make bzip2 ; yum install -y iconv-devel
(Note that this command will also install the perl-Error and perl-Git dependencies)
2) Create an rvm user and group.
groupadd rvm useradd -g rvm rvm
3) Add the root user to the rvm group (required for installation)
usermod -a -G rvm root
4) Install Ruby 1.9.2 using RVM.
# rvm install 1.9.2 -C --with-zlib-dir=/usr/local/rvm/src/ Installing Ruby from source to: /usr/local/rvm/rubi while depending on your cpu(s)... ruby-1.9.2-p180 - #fetching ruby-1.9.2-p180 - #extracting ruby-1.9.2-p180 to /u ruby-1.9.2-p180 - #extracted to /usr/local/rvm/src/ ruby-1.9.2-p180 - #configuring ruby-1.9.2-p180 - #compiling ruby-1.9.2-p180 - #installing ruby-1.9.2-p180 - Updating #rubygems to the latest. Removing old Rubygems files... Installing rubygems dedicated to ruby-1.9.2-p180... Installing rubygems for /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby Installation of rubygems completed successfully. ruby-1.9.2-p180 - Updating #rubygems to the latest. Removing old Rubygems files... Installing rubygems dedicated to ruby-1.9.2-p180... Installing rubygems for /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/ruby Installation of rubygems completed successfully. ruby-1.9.2-p180 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake). ruby-1.9.2-p180 - #importing default gemsets (/usr/local/rvm/gemsets/) Install of ruby-1.9.2-p180 - #complete
7) Set the RVM default to version 1.9.2
# rvm --default use 1.9.2 Using /usr/local/rvm/gems/ruby-1.9.2-p180
8) Verify that Ruby version 1.9.2 was installed successfully.
# ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
9) Add this environment variable to root’s .bash_profile file.
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm"
10) Install rails.
# gem install rails Fetching: activesupport-3.0.5.gem (100%) Fetching: builder-2.1.2.gem (100%) Fetching: i18n-0.5.0.gem (100%) ... Installing RDoc documentation for railties-3.0.5... Installing RDoc documentation for bundler-1.0.10... Installing RDoc documentation for rails-3.0.5...< /pre>