ruby的升级过程

 CentOS 5.5下的ruby版本有些旧,今天需要做一些测试,需要升级ruby, 以下是升级过程:

  
  
  
  
  1. CentOS release 5.5 (Final) 

系统自带的ruby版本:

  
  
  
  
  1. # ruby -v 
  2. ruby 1.8.5 (2006-08-25) [x86_64-linux] 
  3. # which ruby 
  4. /usr/bin/ruby 

先安装 RVM 从github repository.

  
  
  
  
  1. # $ bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) 

使用rvm工具来安装最新版的ruby 1.9.3

  
  
  
  
  1. # rvm install 1.9.3 
  2.    Extracting rubygems-1.8.10 ... 
  3.    Removing old Rubygems files... 
  4.    Installing rubygems-1.8.10 for ruby-1.9.3-p0 ... 
  5.    Installation of rubygems completed successfully. 
  6.    ruby-1.9.3-p0 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake). 
  7.    ruby-1.9.3-p0 - #importing default gemsets (/usr/local/rvm/gemsets/) 
  8.    Install of ruby-1.9.3-p0 - #complete 

添加至系统变量.

  
  
  
  
  1. # vim /etc/profile
  2. # 添加如下行.
  3.   [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 
  4. # source /etc/profile 

输入type rvm, 如输出下面信息则表示安装正确.

  
  
  
  
  1. # type rvm | head -1 
  2.    rvm is a function 

新版本ruby的路径.

  
  
  
  
  1. # /usr/local/rvm/bin/ruby-1.9.3-p0 -v 
  2.    ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] 

使用最新安装的版本替换系统自带的旧版本的ruby.

  
  
  
  
  1. # rvm use 1.9.3 
  2.    Using /usr/local/rvm/gems/ruby-1.9.3-p0 
  3.  
  4. # rvm use 1.9.3 --default 
  5.    Using /usr/local/rvm/gems/ruby-1.9.3-p0 

已经被替换了.

  
  
  
  
  1. # which ruby 
  2.    /usr/local/rvm/rubies/ruby-1.9.3-p0/bin/ruby 

再直接执行ruby命令查看版本号.

  
  
  
  
  1. # ruby -v 
  2.    ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] 

升级完成了.

参考学习站点: 

  
  
  
  
  1. http://beginrescueend.com/rvm/basics/ 

 

你可能感兴趣的:(centos,职场,Ruby,休闲)