參考連接:https://blog.csdn.net/qq_26440803/article/details/82717244
在線安裝ruby
使用yum在線安裝ruby,安裝的版本為2.0.0。
yum install ruby
ruby -v
添加ruby倉庫
添加aliyun鏡像並檢測Ruby版本
gem sources -a http://mirrors.aliyun.com/rubygems/
ruby -v
安裝RAM
RAM(Ruby Version Manager )是一款RAM的命令行工具,可以使用RAM輕松安裝,管理Ruby版本。RVM包含了Ruby的版本管理和Gem庫管理(gemset)
可以使用如下命令進行安裝RAM:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
出現如下信息代表安裝成功:
GPG verified '/home/sidian/.rvm/archives/rvm-1.29.10.tgz'
Installing RVM to /home/sidian/.rvm/
Adding rvm PATH line to /home/sidian/.profile /home/sidian/.mkshrc /home/sidian/.bashrc /home/sidian/.zshrc.
Adding rvm loading line to /home/sidian/.profile /home/sidian/.bash_profile /home/sidian/.zlogin.
Installation of RVM in /home/sidian/.rvm/ is almost complete:
* To start using RVM you need to run `source /home/sidian/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
👉 Donate: https://opencollective.com/rvm/donate
更新配置文件,使其立馬生效:
source /etc/profile.d/rvm.sh 我是執行這個`source /home/sidian/.rvm/scripts/rvm`
查看RVM版本信息,如果可以代表安裝成功。
rvm -v
接下來查看Ruby版本:
rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.7]
[ruby-]2.4[.4]
[ruby-]2.5[.1]
[ruby-]2.6[.0-preview2]
ruby-head
# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby-9.1[.17.0]
jruby[-9.2.0.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.100]
rbx-head
# TruffleRuby
truffleruby[-1.0.0-rc2]
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
mruby-1.3.0
mruby-1[.4.0]
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# Topaz
topaz
# MagLev
maglev-1.0.0
maglev-1.1[RC1]
maglev[-1.2Alpha4]
maglev-head
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
安裝Ruby,從上面查到的信息隨便找一個比2.2.2版本要高的就行:
rvm install 2.5
出現如下信息,代表安裝成功:
[sidian@VM_0_17_centos ruby_study]$ rvm install 2.5 Searching for binary rubies, this might take some time. No binary rubies available for: centos/7/x86_64/ruby-2.5.7. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for centos. Installing requirements for centos. Installing required packages: patch, autoconf, automake, bison, gcc-c++, libtool, patch, readline-devel, sqlite-devel......| Requirements installation successful. Installing Ruby from source to: /home/sidian/.rvm/rubies/ruby-2.5.7, this may take a while depending on your cpu(s)... ruby-2.5.7 - #downloading ruby-2.5.7, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 77 13.1M 77 10.2M 0 0 14986 0 0:15:20 0:11:55 0:03:25 23048
這里的下載比較慢,需要等待比較長時間
驗證版本:
成功升級。
注意:
如果使用rvm安裝發現下載緩慢,可以考慮刪除原來的倉庫地址,只保留阿里雲鏡像。
gem sources --remove https://rubygems.org/
————————————————
版權聲明:本文為CSDN博主「唯一昵稱真難」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/qq_26440803/java/article/details/82717244