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. SpringBoot2.0.2 不使用parent作为maven单继承方式操作 : org.springframework.boot : spring-boot-dependencies : 2.0.2.RELEASE

    1.pom配置方式 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="h ...

  2. python中的分号

    很多编程语言是以分号作为一行代码的的结束标志,但是在Python中不是这样的,而是靠缩进来识别程序结构. Python中一行代码以分号结束,并不是必须的,准确来说是不被推荐的,因为加上分号就是画蛇添足 ...

  3. php 验证码 图像存在错误 无法显示 解决方法

    <?php $height = 300; $width = 300; $im = imagecreatetruecolor($width, $height); $white = imagecol ...

  4. PHP实现视频文件上传完整实例

    这篇文章主要介绍了PHP实现视频文件上传的技巧,包含了PHP配置信息的设计及大文件的处理,需要的朋友可以参考下    本文以一个完整实例的形式实现了视频文件上传的功能.虽然是比较基础的应用,仍有一定的 ...

  5. (转)VmWare下安装CentOS6图文安装教程

    转自:http://www.cnblogs.com/seesea125/archive/2012/02/25/2368255.html 第一次使用VmWare和CentOS6,中间遇到不少问题,记性不 ...

  6. (转)WAMP多站点配置

    转自:http://wislab.net/archives/43.html Wamp正在被广泛使用,其傻瓜式的安装配置,使得我们可以得心应手地完成以往较为烦琐的服务器环境搭建过程,直接进入到网页程序的 ...

  7. POJ3666 线性dp_离散化_贪心

    POJ3666 线性dp_离散化_贪心 就DP而言这个题不算难,但是难就难在贪心,还有离散化的思想上 题目大意:n个土堆,问你最少移动多少单位的图,可以使得这n个土堆变成单调的 dp[i][j]表示前 ...

  8. LED点阵书写显示

    LED点阵书写显示屏   摘要:随着时代的发展,数字电子技术已经普及到我们生活,工作,科研,各个领域,而LED显示以其组构方式灵活.显示稳定.功耗低.寿命长.技术成熟.成本低廉等特点在车站.证券所.运 ...

  9. 分形之谢尔宾斯基(Sierpinski)三角形

    谢尔宾斯基三角形(英语:Sierpinski triangle)是一种分形,由波兰数学家谢尔宾斯基在1915年提出,它是一种典型的自相似集.也有的资料将其称之为谢尔宾斯基坟垛. 其生成过程为: 取一个 ...

  10. [leetcode 14]Longest Common Prfix

    1 题目: Write a function to find the longest common prefix string amongst an array of strings. Hide Ta ...