1、apt-get安装

可以使用apt-cache查询功能,找到对应的可用的ruby版本。

$ sudo apt-cache search ruby
#这个结果很长,我只截取最后与ruby有关的部分
ruby1. - Interpreter of object-oriented scripting language Ruby 1.8
ruby1.-dev - Header files for compiling extension modules for the Ruby 1.8
ruby1.-examples - Examples for Ruby 1.8
rubygems - package management framework for Ruby libraries/applications
rubygems1. - Transitional package for rubygems
rubygems-doc - Transitional package for rubygems
ruby1.9.1-full - Ruby 1.9. full installation
ruby1.-full - Ruby 1.8 full installation
ruby-switch - switch between different Ruby interpreters
ruby2. - Interpreter of object-oriented scripting language Ruby
libruby2. - Libraries necessary to run Ruby 2.1
ruby2.-dev - Header files for compiling extension modules for the Ruby 2.1
ruby2.-tcltk - Ruby/Tk for Ruby 2.1
ruby2.-doc - Documentation for Ruby 2.1
ruby2. - Interpreter of object-oriented scripting language Ruby
libruby2. - Libraries necessary to run Ruby 2.2
ruby2.-dev - Header files for compiling extension modules for the Ruby 2.2
ruby2.-tcltk - Ruby/Tk for Ruby 2.2
ruby2.-doc - Documentation for Ruby 2.2
ruby2. - Interpreter of object-oriented scripting language Ruby
ruby2.-doc - Documentation for Ruby 2.3
libruby2. - Libraries necessary to run Ruby 2.3
ruby2.-dev - Header files for compiling extension modules for the Ruby 2.3
ruby2.-tcltk - Ruby/Tk for Ruby 2.3
libruby2. - Libraries necessary to run Ruby 2.4
ruby2.-dev - Header files for compiling extension modules for the Ruby 2.4
ruby2. - Interpreter of object-oriented scripting language Ruby
ruby2.-doc - Documentation for Ruby 2.4

可以看到官方目前支持较多版本,

安装样例

sudo apt-get install ruby #自动安装最新版本
sudo apt-get install ruby2.0

无法指定子版本,只能用repo已有的版本。

2、使用brightbox ppa仓库安装

这是一个repo方案,已经更新到2.4版本,参考:https://www.brightbox.com/docs/ruby/ubuntu/

If you’re using Ubuntu 14.04 (Trusty) or newer then you can add the package repository like this

$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
$ sudo apt-get install ruby1.9.3 ruby1.9.3-dev

无法指定子版本,只能用repo已有的版本。

3、利用rvm安装

$ curl -L get.rvm.io | bash -s stable
$ source ~/.bashrc
$ source ~/.bash_profile
$ source ~/.profile
$ rvm -v
$ rvm list known
$ rvm install 2.2
$ ruby -v
ruby 2.2.6p396 (-- revision ) [x86_64-linux] 如果想在Ubuntu上安装多个Ruby版本,那么可以使用下面的命令来指定使用rvm作为默认的Ruby版本管理。
rvm use ruby 1.9. --default
rvm use ruby 1.9.3-p551 --default #制定子版本

可以指定子版本,比如 rvm install 1.9.3-p551

附rvm list known结果参考。

$ rvm list known
Warning, new version of rvm available '1.29.2', you are using older version '1.29.1'.
You can disable this warning with: echo rvm_autoupdate_flag= >> ~/.rvmrc
You can enable auto-update with: echo rvm_autoupdate_flag= >> ~/.rvmrc
# MRI Rubies
[ruby-]1.8.[-p420]
[ruby-]1.8.[-head] # security released on head
[ruby-]1.9.[-p431]
[ruby-]1.9.[-p330]
[ruby-]1.9.[-p551]
[ruby-]2.0.[-p648]
[ruby-]2.1[.]
[ruby-]2.2[.]
[ruby-]2.3[.]
[ruby-]2.4[.]
ruby-head # for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2 # JRuby
jruby-1.6[.]
jruby-1.7[.]
jruby[-9.1.7.0]
jruby-head # Rubinius
rbx-[.4.3]
rbx-2.3[.]
rbx-2.4[.]
rbx-[.5.8]
rbx[-3.71]
rbx-head # Opal
opal # Minimalistic ruby implementation - ISO :
mruby-1.0.
mruby-1.1.
mruby-[.2.0]
mruby[-head] # Ruby Enterprise Edition
ree-1.8.
ree[-1.8.][-2012.02] # Topaz
topaz # MagLev
maglev[-head]
maglev-1.0. # Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head # IronRuby
ironruby[-1.1.]
ironruby-head

结果参考

4、编译安装

参考前一笔记:ubuntu编译安装ruby1.9.3,从p551降级到p484

Best Wishes!Any question pls fell free to contact me!

最新文章

  1. Redis数据库
  2. linux下使用fork,exec,waitpid模拟system函数
  3. Linux Found a swap file by the name filename
  4. javascript向上向下取整
  5. git stash恢复
  6. windows8运行php Composer出现SSL报错的问题
  7. 求最长回文子串——Manacher算法
  8. poj 1741 Tree(点分治)
  9. 3G? 2G? 2.5G? 4G? 与 WIFI, GPRS,CDMA 3G无线上网
  10. bzoj2038
  11. python zip文件密码爆破
  12. Codeforces 360C Levko and Strings dp
  13. (hdu 7.1.8)Quoit Design(最低点——在n一个点,发现两点之间的最小距离)
  14. Apriori算法-位运算-C语言
  15. ROS(indigo) 用于机器人控制的图形化编程工具--code_it robot_blockly
  16. Ocelot中文文档-请求聚合
  17. 【官方下载】EasyCMDB官方基础版免费下载使用!
  18. CentOS 7 NAT模式LVS搭建
  19. python的Socket网络编程
  20. JPA(五):映射关联关系------映射单向多对一的关联关系

热门文章

  1. c#利用循环将类实例化为对象
  2. 如何在MYSQL下所有指定数据库名下执行SQL
  3. 诡异的 ERROR 1045 (28000): Access denied for user 错误
  4. Is Docker Good for Your Database?
  5. (转)MVC语法-基础
  6. android ActivityGroup接收不到onActivityResult
  7. jQuery插件初级练习3答案
  8. 初次见识结构体与map的区别
  9. php+sqlserver之如何操作sqlserver数据库
  10. cxGrid的FilterRow默认自动匹配左边%而不是右边%