Ruby是一个动态的,面向对象的编程语言。我们正在使用RVM,它是Ruby版本管理,使得更容易在Linux平台上安装Ruby。 RVM也是管理Ruby多版本无冲突的,我们可以使用一个命令切换系统,以适应Ruby的任何版本。 本文将帮助您如何在CentOS,RedHat系统中使用RVM安装Ruby 2.0.0。要安装Ruby使用以下链接其他版本
最新的稳定:
Ruby2.1.1
老版本:
Ruby1.9.3
第1步:安装所需的程序包
首先,我们需要使用下面的命令我们的系统上安装Ruby所有需要的软件包。
# 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
第2步:安装RVM(Ruby的版本管理器)
使用以下命令在系统上安装RVM的最新稳定版本。这个命令会自动下载所有必需的文件并安装在系统上。
# curl -L get.rvm.io | bash -s stable
安装Ruby之前,现在设置系统环境。使用下面的命令设置RVM环境。
# source /etc/profile.d/rvm.sh
第3步:安装Ruby
完成RVM环境的设置之后,可以通过安装下面的命令Ruby语言。
# rvm install 2.0.0
[样本输出]
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/6/i386/ruby-2.0.0-p451.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.0.0-p451, this may take a while depending on your cpu(s)...
ruby-2.0.0-p451 - #downloading ruby-2.0.0-p451, this may take a while depending on your connection...
** Resuming transfer from byte position 24576
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 10.2M 100 10.2M 0 0 188k 0 0:00:55 0:00:55 --:--:-- 414k
ruby-2.0.0-p451 - #extracting ruby-2.0.0-p451 to /usr/local/rvm/src/ruby-2.0.0-p451...
ruby-2.0.0-p451 - #applying patch /usr/local/rvm/patches/ruby/changeset_r45225.diff.
ruby-2.0.0-p451 - #applying patch /usr/local/rvm/patches/ruby/changeset_r45240.diff.
ruby-2.0.0-p451 - #applying patch /usr/local/rvm/patches/ruby/ssl_no_ec2m.patch.
ruby-2.0.0-p451 - #configuring..................................................
ruby-2.0.0-p451 - #post-configuration.
ruby-2.0.0-p451 - #compiling............................................................................
ruby-2.0.0-p451 - #installing.............................
ruby-2.0.0-p451 - #making binaries executable..
ruby-2.0.0-p451 - #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 96653 0 0:00:04 0:00:04 --:--:-- 136k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.0.0-p451 - #extracting rubygems-2.2.2...
ruby-2.0.0-p451 - #removing old rubygems.........
ruby-2.0.0-p451 - #installing rubygems-2.2.2...............
ruby-2.0.0-p451 - #gemset created /usr/local/rvm/gems/ruby-2.0.0-p451@global
ruby-2.0.0-p451 - #importing gemset /usr/local/rvm/gemsets/global.gems.....................................
ruby-2.0.0-p451 - #generating global wrappers.........
ruby-2.0.0-p451 - #gemset created /usr/local/rvm/gems/ruby-2.0.0-p451
ruby-2.0.0-p451 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.0.0-p451 - #generating default wrappers.........
ruby-2.0.0-p451 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.0.0-p451 - #complete
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on an up to date linux system.
This may have known and unaccounted for security vulnerabilities.
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
第4步:设置默认Ruby版本
使用RVM命令设置默认Ruby版本由应用程序使用。
# rvm use 2.0.0 --default
Using /usr/local/rvm/gems/ruby-2.0.0-p451
使用以下命令可以查看当前的Ruby版本使用。
# ruby --version
ruby 2.0.0p451 (2014-02-24 revision 45167) [i686-linux]
恭喜您,您已经成功地在系统上安装Ruby。 请阅读我们的下一篇文章,
Ruby与Apache集成的简单的步骤,Web服务器。
参考文献: 1. http://rvm.io/rubies/installing