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!

ubuntu安装ruby的几种方法总结的更多相关文章

  1. ubuntu安装jdk的两种方法

    方法一: 这种方法比较简单,保证虚拟机网络畅通就可以了 sudo apt-get update sudo apt-get install default-jre sudo apt-get instal ...

  2. Ubuntu下安装程序的三种方法(转)

    引言 在Ubuntu当中,安装应用程序我所知道的有三种方法,分别是apt-get,dpkg安装deb和make install安装源码包三种.下面针对每一种方法各举例来说明. 一.apt-get方法 ...

  3. linux安装软件的几种方法----linux下编译安装软件的一般步骤

    linux安装软件的几种方法: 一.rpm包安装方式步骤: 1.找到相应的软件包,比如soft.version.rpm,下载到本机某个目录: 2.打开一个终端,su -成root用户: 3.cd so ...

  4. MyEclipse安装插件的几种方法 转

    http://www.cnblogs.com/pharen/archive/2012/02/08/2343342.html MyEclipse安装插件的几种方法 本文讲解MyEclipse(MyEcl ...

  5. Fedora安装qt总结四种方法

    在fedora上安装qt有四种方法,本人由于初次接触fedora,所以还是耐心的把三个方法都测试了一遍. 1.  下载源码,手动编译,选择路径安装,请参考<fedora15下搭建QT开发环境及编 ...

  6. Ubuntu 安装 JDK8 的两种方式

    ubuntu 安装jdk 的两种方式: 1:通过ppa(源) 方式安装. 2:通过官网下载安装包安装. 这里推荐第1种,因为可以通过 apt-get upgrade 方式方便获得jdk的升级 使用pp ...

  7. 7.1 安装软件包的三种方法 7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法 7.5 yum搭建本地仓库

    7.1 安装软件包的三种方法 7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法 7.5 yum搭建本地仓库 三种方法 rpm工具----->类型windows下的exe程序 ...

  8. 在CentOS7.4中安装jdk的几种方法及配置环境变量

    在CentOS7.4中安装jdk的几种方法及配置环境变量 一.下载jdk jdk下载地址:http://www.oracle.com/technetwork/java/javase/downloads ...

  9. 安装软件包的三种方法、RPM包介绍、rpm、yum工具用法、yum搭建本地仓库

    第5周第3次课(4月18日) 课程内容: 7.1 安装软件包的三种方法7.2 rpm包介绍7.3 rpm工具用法7.4 yum工具用法7.5 yum搭建本地仓库 7.1 安装软件包的三种方法 rpm工 ...

随机推荐

  1. IE 8 浏览器 F12 调试功能无法使用

      “按下F12之后,开发人员工具在桌面上看不到,但是任务栏里有显示.将鼠标放在任务栏的开发人员工具上,出现一片透明的区域,选中之后却出不来.将鼠标移动到开发人员工具的缩略图上,右键-最大化,工具就全 ...

  2. 1045 Favorite Color Stripe 动态规划

    1045 Favorite Color Stripe 1045. Favorite Color Stripe (30)Eva is trying to make her own color strip ...

  3. DeepFace和GAN

    由于换脸技术的影响,现在造假视频的成本越来越低.AI换脸视频也越来越热门,甚至有一些已经达到了以假乱真的程度.虽然有明星反对表示无奈,可是.... 据报道,2018年,arXiv上发布了902篇GAN ...

  4. How to fix "FAILURE DURING CONVERSION TO COFF: FILE INVALID OR CORRUPT"

    Error LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt appear ...

  5. 20155326 2016-2017-2《Java程序设计》课程总结

    20155326 2016-2017-2<Java程序设计>课程总结 (按顺序)每周作业链接汇总 20155326刘美岑的第一次作业:第一次写博客,写下了对java的期待 20155326 ...

  6. redis链接

    参考资料:http://www.runoob.com/redis/redis-connection.htmlRedis 连接Redis 连接命令主要是用于连接 redis 服务.实例以下实例演示了客户 ...

  7. hdu 4941 map的使用

    http://acm.hdu.edu.cn/showproblem.php?pid=4941 给定N,M和K,表示在一个N*M的棋盘上有K个棋子,给出K个棋子的位置和值,然后是Q次操作,对应的是: 1 ...

  8. HDU 2476 区间DP-刷字符问题-思维考察

    区间DP-刷字符问题-思维考察 翻译了一下这个题,一看还是有点难以入手,标明了是区间DP问题,但是如何DP呢 来捋一捋思路吧 dp[i][j]肯定是从i刷到j所要的次数但是它的i和j是s1串还是s2串 ...

  9. C++ const方法及对象

    一.整体代码 01.cpp #include <iostream> using namespace std; class Test { public: Test(int x) : x_(x ...

  10. zeppelin中运行spark streaming kakfa & 实时可视化

    notebook方式运行spark程序是一种比较agile的方式,一方面可以体验像spark-shell那样repl的便捷,同时可以借助notebook的作图能力实现快速数据可视化,非常方便快速验证和 ...