Linux安装ruby

11 篇文章 0 订阅
1 篇文章 0 订阅
[url]https://rvm.io/[/url] 官方网站
[url]https://github.com/rvm/rvm[/url] 官方离线包

在线安装步骤:
# \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
修改安装命令:
# \curl -sSL https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
或者
# curl -L https://get.rvm.io | bash -s stable
或者
# curl -sSL https://get.rvm.io | bash -s stable
# 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.

# rvm -v
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

# gem -v
2.4.8
# gem sources -l
*** CURRENT SOURCES ***

https://rubygems.org/

将gem的源更换为淘宝网,步骤如下:
# cd /usr/local/rvm/src/ruby-2.2.1/ext/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
# make
linking shared-object zlib.so
# 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
# cd /usr/local/rvm/src/ruby-2.2.1/ext/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
# make

# gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources
# gem sources --add http://ruby.taobao.org/
或者
# gem sources -a https://ruby.taobao.org/
# gem sources -l
*** CURRENT SOURCES ***

http://ruby.taobao.org


----------------------------------------------------------------------------------


下面是离线安装步骤:

在官方下载rvm-master.zip离线安装包并解压:
# cd /opt
# mkdir ruby
# cd ruby
# ls
rvm-master.zip
# unzip rvm-master.zip -d /opt/ruby/
# ls
rvm-master rvm-master.zip
# cd rvm-master
# ./install
# source ~/.bashrc
# source ~/.bash_profile
# rvm list known
# rvm -v
rvm 1.26.11 (manual) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
#


rvm安装ruby:
在官方下载ruby-2.1.8.tar.gz、ruby-2.1.8.tar.bz2和rubygems-2.5.1.tgz离线安装包并拷贝到/usr/local/rvm/archives:
# pwd
/usr/local/rvm/archives
# ls
ruby-2.1.8.tar.bz2 ruby-2.1.8.tar.gz
# rpm -ivh libyaml-devel-0.1.3-1.el6.rf.x86_64.rpm --nodeps
# rpm -ivh readline-devel-6.0-4.el6.x86_64.rpm --nodeps
# rpm -ivh libffi-devel-3.0.5-3.2.el6.x86_64.rpm --nodeps
# rpm -ivh automake-1.11.1-4.el6.noarch.rpm --nodeps
# rpm -ivh libtool-2.2.6-15.5.el6.x86_64.rpm --nodeps
# rpm -ivh bison-2.4.1-5.el6.x86_64.rpm --nodeps
# rpm -ivh sqlite-devel-3.6.20-1.el6.x86_64.rpm --nodeps
# rvm install ruby-2.1.8
# rvm list
切换Ruby版本:
# rvm use 2.1.8
如果想设置为默认版本,这样一来以后新打开的控制台默认的Ruby就是这个版本:
# rvm use 2.1.8 --default
卸载一个已安装版本:
# rvm remove 2.1.8


安装rubygems:
在官方下载rubygems-2.5.1.tgz安装包并解压到/usr/local/rvm/src/目录下:
# tar -zxvf rubygems-2.5.1.tgz -C /usr/local/rvm/src/
# cd /usr/local/rvm/src/rubygems-2.5.1
# rvm --create ruby-2.1.8
# rvm use ruby-2.1.8
Using /usr/local/rvm/gems/ruby-2.1.8
查看gem安装在哪里:
# gem list –l

*** LOCAL GEMS ***


#

# vi .bash_profile
......

PATH=$PATH:$HOME/bin

# export PATH

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

......


# ruby -v
ruby 2.1.8p440 (2015-12-16 revision 53160) [x86_64-linux]

# 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
# ruby setup.rb
......

RubyGems installed the following executables:
/usr/local/rvm/rubies/ruby-2.1.8/bin/gem

......


# /usr/local/rvm/rubies/ruby-2.1.8/bin/gem -v
2.5.1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值