zoukankan      html  css  js  c++  java
  • ubuntu安装ruby的几种方法总结

    1、apt-get安装

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

    $ sudo apt-cache search ruby
    #这个结果很长,我只截取最后与ruby有关的部分
    ruby1.8 - Interpreter of object-oriented scripting language Ruby 1.8
    ruby1.8-dev - Header files for compiling extension modules for the Ruby 1.8
    ruby1.8-examples - Examples for Ruby 1.8
    rubygems - package management framework for Ruby libraries/applications
    rubygems1.8 - Transitional package for rubygems
    rubygems-doc - Transitional package for rubygems
    ruby1.9.1-full - Ruby 1.9.1 full installation
    ruby1.8-full - Ruby 1.8 full installation
    ruby-switch - switch between different Ruby interpreters
    ruby2.1 - Interpreter of object-oriented scripting language Ruby
    libruby2.1 - Libraries necessary to run Ruby 2.1
    ruby2.1-dev - Header files for compiling extension modules for the Ruby 2.1
    ruby2.1-tcltk - Ruby/Tk for Ruby 2.1
    ruby2.1-doc - Documentation for Ruby 2.1
    ruby2.2 - Interpreter of object-oriented scripting language Ruby
    libruby2.2 - Libraries necessary to run Ruby 2.2
    ruby2.2-dev - Header files for compiling extension modules for the Ruby 2.2
    ruby2.2-tcltk - Ruby/Tk for Ruby 2.2
    ruby2.2-doc - Documentation for Ruby 2.2
    ruby2.3 - Interpreter of object-oriented scripting language Ruby
    ruby2.3-doc - Documentation for Ruby 2.3
    libruby2.3 - Libraries necessary to run Ruby 2.3
    ruby2.3-dev - Header files for compiling extension modules for the Ruby 2.3
    ruby2.3-tcltk - Ruby/Tk for Ruby 2.3
    libruby2.4 - Libraries necessary to run Ruby 2.4
    ruby2.4-dev - Header files for compiling extension modules for the Ruby 2.4
    ruby2.4 - Interpreter of object-oriented scripting language Ruby
    ruby2.4-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 (2016-11-15 revision 56800) [x86_64-linux]
    
    如果想在Ubuntu上安装多个Ruby版本,那么可以使用下面的命令来指定使用rvm作为默认的Ruby版本管理。
    rvm use ruby 1.9.3 --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=0 >> ~/.rvmrc
    You can enable  auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc
    # 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[.6]
    [ruby-]2.3[.3]
    [ruby-]2.4[.0]
    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[.26]
    jruby[-9.1.7.0]
    jruby-head
    
    # Rubinius
    rbx-1[.4.3]
    rbx-2.3[.0]
    rbx-2.4[.1]
    rbx-2[.5.8]
    rbx[-3.71]
    rbx-head
    
    # Opal
    opal
    
    # Minimalistic ruby implementation - ISO 30170:2012
    mruby-1.0.0
    mruby-1.1.0
    mruby-1[.2.0]
    mruby[-head]
    
    # Ruby Enterprise Edition
    ree-1.8.6
    ree[-1.8.7][-2012.02]
    
    # Topaz
    topaz
    
    # MagLev
    maglev[-head]
    maglev-1.0.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.3]
    ironruby-head
    结果参考

     

    4、编译安装

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

     

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

  • 相关阅读:
    CRM后期修改实体,新增货币类型字段 需要注意的问题
    CRM setValue方法日期类型字段赋值
    win10 ie11 以管理员身份运行才正常
    博客随缘更新,更多内容访问语雀知识库!
    解决Vulnhub靶机分配不到IP问题
    栈迁移原理图示
    【python】青果教务系统模拟登陆
    【二进制】CTF-Wiki PWN里面的一些练习题(Basic-ROP篇)
    2019"深思杯"山东省大学生网络安全技能大赛部分wp
    【web】docker复现环境踩坑
  • 原文地址:https://www.cnblogs.com/wangbaobao/p/7239597.html
Copyright © 2011-2022 走看看