在CentOS,RedHat中使用RVM安装Ruby1.9.3(或多个Ruby版)

Ruby编程语言变得更受追捧。 Ruby语言是由“Matz”创建并首次出版于1995年。本文将帮助您安装在CentOS上安装Ruby语言,使用RVM Redhat系统。在这篇文章中,我使用CentOS的6.5。 RVM提供了方便的命令集,以在单个服务器上安装Ruby的单个或多个版本。

第1步:升级包

这是您的系统保持最新与最新的软件包的最佳实践。下面的命令运行之前,请确保更新不会影响到您运行的应用程序(如果有的话)在服务器上其他跳过它
# yum update

第2步:安装推荐包

有在Linux上运行Ruby需要一些开发库。使用下面的命令来使用yum服务器上安装推荐的软件包。
# yum install gcc-c++ patch readline readline-devel zlib zlib-devel
# yum install libyaml-devel libffi-devel openssl-devel make
# yum install bzip2 autoconf automake libtool bison iconv-devel

第3步:安装RVM(Ruby的版本管理器)

使用以下命令在系统上安装RVM的最新稳定版本。这个命令会自动下载所有必需的文件并安装在系统上。
# 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

第4步:设置RVM环境

安装后,RVM首先我们需要设置RVM的环境中使用下面的命令。
# source /etc/profile.d/rvm.sh

第5步:安装必需的Ruby版本

RVM提供选项,以在单个系统上管理多个版本的Ruby。使用下面的命令来安装Ruby的所需的版本。
# rvm install 1.9.3
[样本输出]
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

第6步:安装另一个版本 ( 如果需要 )

如果你想使用Ruby的多个版本,也可以使用其他RVM,跳过此步骤进行安装。
# rvm install 1.8.6

第7步:设置默认的Ruby版本

使用RVM命令设置默认Ruby版本由应用程序使用。
# rvm use 1.9.3 --default 

Using /usr/local/rvm/gems/ruby-1.9.3-p545
第8步:检查当前的Ruby版本
使用以下命令可以查看当前的Ruby版本。
# ruby --version

ruby 1.9.3p545 (2014-02-24 revision 45159) [i686-linux]
我希望上面的步骤将帮助您使用RVM安装多个Ruby版本。
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏