https://rvm.io/ 官方网站
https://github.com/rvm/rvm 官方离线包
在线安装步骤:
[root@testagent ~]# \curl -sSL https://get.rvm.io | bash -s stable
curl: (6) Couldn't resolve host 'get.rvm.io'
在浏览器里访问https://get.rvm.io会跳转到下面的地址
https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-
installer
修改安装命令:
[root@testagent ~]# \curl -sSL https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
或者
[root@testagent ~]# curl -L https://get.rvm.io | bash -s stable
或者
[root@testagent ~]# curl -sSL https://get.rvm.io | bash -s stable
[root@testagent ~]# source /usr/local/rvm/scripts/rvm
如果是在Centos上可以按下面操作:
* 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@testagent rvm]# rvm -v
rvm 1.26.11 (latest) by
Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
[root@testagent ~]# gem -v
2.4.8
[root@testagent ~]# gem sources -l
*** CURRENT SOURCES ***
https://rubygems.org/
将gem的源更换为
淘宝网,步骤如下:
[root@testagent zlib]# cd /usr/local/rvm/src/ruby-2.2.1/ext/zlib
[root@testagent zlib]# ruby ./extconf.rb
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for crc32_combine() in zlib.h... yes
checking for adler32_combine() in zlib.h... yes
checking for z_crc_t in zlib.h... no
creating Makefile
[root@testagent zlib]# make
linking shared-object zlib.so
[root@testagent zlib]# make install
/usr/bin/install -c -m 0755 zlib.so /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/x86_64-linux
[root@testagent zlib]# cd /usr/local/rvm/src/ruby-2.2.1/ext/openssl/
[root@testagent openssl]# ruby extconf.rb
checking for t_open() in -lnsl... no
checking for
socket() in -lsocket... no
checking for assert.h... yes
checking for openssl/ssl.h... no
[root@testagent openssl]# make
[root@testagent ~]# gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources
[root@testagent ~]# gem sources --add http://ruby.taobao.org/
或者
[root@testagent ~]# gem sources -a https://ruby.taobao.org/
[root@testagent ~]# gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org
----------------------------------------------------------------------------------
下面是离线安装步骤:
在官方下载rvm-master.zip离线安装包并解压:
[root@testgit /]# cd /opt
[root@testgit opt]# mkdir ruby
[root@testgit opt]# cd ruby
[root@testgit ruby]# ls
rvm-master.zip
[root@testgit ruby]# unzip rvm-master.zip -d /opt/ruby/
[root@testgit ruby]# ls
rvm-master rvm-master.zip
[root@testgit ruby]# cd rvm-master
[root@testgit rvm-master]# ./install
[root@testgit rvm-master]# source ~/.bashrc
[root@testgit rvm-master]# source ~/.bash_profile
[root@testgit rvm-master]# rvm list known
[root@testgit /]# rvm -v
rvm 1.26.11 (manual) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
[root@testgit /]#
rvm安装ruby:
在官方下载ruby-2.1.8.tar.gz、ruby-2.1.8.tar.bz2和rubygems-2.5.1.tgz离线安装包并拷贝到/usr/local/rvm/archives:
[root@testgit archives]# pwd
/usr/local/rvm/archives
[root@testgit archives]# ls
ruby-2.1.8.tar.bz2 ruby-2.1.8.tar.gz
[root@testgit rpmrubylib]# rpm -ivh libyaml-devel-0.1.3-1.el6.rf.x86_64.rpm --nodeps
[root@testgit rpmrubylib]# rpm -ivh readline-devel-6.0-4.el6.x86_64.rpm --nodeps
[root@testgit rpmrubylib]# rpm -ivh libffi-devel-3.0.5-3.2.el6.x86_64.rpm --nodeps
[root@testgit rpmrubylib]# rpm -ivh automake-1.11.1-4.el6.noarch.rpm --nodeps
[root@testgit rpmrubylib]# rpm -ivh libtool-2.2.6-15.5.el6.x86_64.rpm --nodeps
[root@testgit rpmrubylib]# rpm -ivh bison-2.4.1-5.el6.x86_64.rpm --nodeps
[root@testgit rpmrubylib]# rpm -ivh sqlite-devel-3.6.20-1.el6.x86_64.rpm --nodeps
[root@testgit archives]# rvm install ruby-2.1.8
[root@testgit archives]# rvm list
切换Ruby
版本:
[root@testgit archives]# rvm use 2.1.8
如果想设置为默认版本,这样一来以后新打开的控制台默认的Ruby就是这个版本:
[root@testgit archives]# rvm use 2.1.8 --default
卸载一个已安装版本:
[root@testgit archives]# rvm remove 2.1.8
安装rubygems:
在官方下载rubygems-2.5.1.tgz安装包并解压到/usr/local/rvm/src/目录下:
[root@testgit rpmrubylib]# tar -zxvf rubygems-2.5.1.tgz -C /usr/local/rvm/src/
[root@testgit rpmrubylib]# cd /usr/local/rvm/src/rubygems-2.5.1
[root@testgit rubygems-2.5.1]# rvm --create ruby-2.1.8
[root@testgit rubygems-2.5.1]# rvm use ruby-2.1.8
Using /usr/local/rvm/gems/ruby-2.1.8
查看gem安装在哪里:
[root@testgit rubygems-2.5.1]# gem list –l
*** LOCAL GEMS ***
[root@testgit rubygems-2.5.1]#
[root@testgit ~]# vi .bash_profile
......
PATH=$PATH:$HOME/bin
# export PATH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
......
[root@testgit rubygems-2.5.1]# ruby -v
ruby 2.1.8p440 (2015-12-16 revision 53160) [x86_64-linux]
[root@testgit rubygems-2.5.1]# ls
appveyor.yml CVE-2013-4363.txt LICENSE.txt setup.rb
bin CVE-2015-3900.txt Manifest.txt test
CODE_OF_CONDUCT.md hide_lib_for_update MIT.txt UPGRADING.rdoc
CONTRIBUTING.rdoc History.txt Rakefile util
CVE-2013-4287.txt lib README.rdoc
[root@testgit rubygems-2.5.1]# ruby setup.rb
......
Ruby
Gems installed the following executables:
/usr/local/rvm/rubies/ruby-2.1.8/bin/gem
......
[root@testgit rubygems-2.5.1]# /usr/local/rvm/rubies/ruby-2.1.8/bin/gem -v
2.5.1