Ruby安装及升级:通过yum –y install ruby*安装即可,还有另外一种情况,ruby和rubygems都已经安装,但没达到dbshards运行的版本(我在使用dbshards软件,它需要ruby更高的版本),
需要升级,升级步骤如下:
升级过程如下:
bash )
从github
repository先安装 RVM。使用rvm工具来安装最新版的ruby 1.8.7
会有类似于以下的输出:
Installing RVM to /usr/local/rvm/
Creating RVM
system user group 'rvm'
# RVM: Shell
scripts enabling management of multiple ruby environments.
# RTFM:
# HELP: (#rvm
on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm/
# Screencast:
# In case of any issues read output of 'rvm requirements'
and/or 'rvm notes'
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.
# root,
#
# Thank you for
using RVM!
# I sincerely
hope that RVM helps to make your life easier and
# more
enjoyable!!!
#
安装1.8.7版本的ruby:
[root@ungeoxliu conf]# /usr/local/rvm/bin/rvm install
1.8.7 ##如果要安装其他的版本, 只需要将1.8.7替换为其他的版本即可(例如:1.9.3)。
添加至环境变量:
# vim /etc/profile
# 添加如下行.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
# source /etc/profile ##使其立即生效,但仅对当前的session生效!
[root@ungeoxliu ~]# type rvm | head -1
rvm is a function ##输出的内容
[root@ungeoxliu ~]# /usr/local/rvm/bin/ruby-1.8.7-p371 -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-linux]
###以下是使用最新安装的版本替换系统自带的旧版本的ruby
[root@ungeoxliu ~]# rvm use 1.8.7
Using /usr/local/rvm/gems/ruby-1.8.7-p371
[root@ungeoxliu ~]# rvm use 1.8.7 --default
Using /usr/local/rvm/gems/ruby-1.8.7-p371
查看是否已经成功升级:
[root@ungeoxliu conf]# which ruby
/usr/local/rvm/rubies/ruby-1.8.7-p371/bin/ruby
[root@ungeoxliu conf]# ruby -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-linux]
[root@ungeoxliu conf]# gem -v
1.8.24
显然已经升级成功!