GNU/Linux >> Linux の 問題 >  >> Cent OS

RVMを使用してCentOS、RedHatにRuby 1.9.3(または複数のRubyバージョン)をインストールします

警告 – Ruby 1.9はサポートが終了し、保守されなくなりました。以下のチュートリアルを使用して、最新バージョンのrubyをインストールしてください

  • 現在の安定– Rubyの最新の安定したリリースをインストールする
  • 以前の安定– Rubyの以前の安定したリリースをインストールする

最近、Rubyプログラミング言語の人気が高まっています。 Ruby言語はまつもとゆきひろ「Matz」によって作成され、1995年に最初に公開されました。この記事は、RVMを使用してCentOS、RedHatシステムにRuby言語をインストールするのに役立ちます。この記事では、CentOS6.5を使用しています。 RVMは、単一または複数のバージョンのRubyを単一のサーバーにインストールするための簡単なコマンドセットを提供します。

ステップ1:パッケージをアップグレードする

システムを最新のパッケージで最新の状態に保つことがベストプラクティスです。以下のコマンドを実行する前に、更新がサーバー上で実行中のアプリ(存在する場合)に影響を与えないことを確認してください。それ以外の場合はスキップしてください

# yum update

ステップ2:推奨パッケージのインストール

LinuxでRubyを実行するために必要な開発ライブラリはほとんどありません。次のコマンドを使用して、yumを使用してサーバーに推奨パッケージをインストールします。

# yum install gcc-c++ patch readline readline-devel zlib zlib-devel
# yum install libyaml-devel libffi-devel openssl-devel make
# yum install bzip2 autoconf automake libtool bison iconv-devel

ステップ3:RVM(Rubyバージョンマネージャー)をインストールする

次のコマンドを使用して、システムに最新の安定バージョンのRVMをインストールします。このコマンドは、必要なすべてのファイルを自動的にダウンロードして、システムにインストールします。

# curl -L get.rvm.io | bash -s stable

[サンプル出力]

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 20511  100 20511    0     0   1120      0  0:00:18  0:00:18 --:--:-- 19722
Downloading https://github.com/wayneeseguin/rvm/archive/stable.tar.gz
Creating group 'rvm'

Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:

  * First you need to add all users that will be using rvm to 'rvm' group,
    and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.

  * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

# Administrator,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: http://rvm.io/help and https://twitter.com/rvm_io

ステップ4:RVM環境をセットアップする

最初にRVMをインストールした後、以下のコマンドを使用してrvm環境をセットアップする必要があります。

# source /etc/profile.d/rvm.sh

ステップ5:必要なRubyバージョンをインストールする

RVMは、単一のシステムで複数のルビーバージョンを管理するオプションを提供します。次のコマンドを使用して、必要なバージョンのRubyをインストールします。

# rvm install 1.9.3

[サンプル出力]

Searching for binary rubies, this might take some time.
No binary rubies available for: centos/6/i386/ruby-1.9.3-p545.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Installing requirements for centos.
Updating system......
Installing required packages: libyaml-devel......
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-1.9.3-p545, this may take a while depending on your cpu(s)...
ruby-1.9.3-p545 - #downloading ruby-1.9.3-p545, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9802k  100 9802k    0     0   217k      0  0:00:45  0:00:45 --:--:--  393k
ruby-1.9.3-p545 - #extracting ruby-1.9.3-p545 to /usr/local/rvm/src/ruby-1.9.3-p545.
ruby-1.9.3-p545 - #applying patch /usr/local/rvm/patches/ruby/GH-488.patch.
ruby-1.9.3-p545 - #applying patch /usr/local/rvm/patches/ruby/ssl_no_ec2m.patch.
ruby-1.9.3-p545 - #configuring..............................................
ruby-1.9.3-p545 - #post-configuration.
ruby-1.9.3-p545 - #compiling...................................................................
ruby-1.9.3-p545 - #installing........................
ruby-1.9.3-p545 - #making binaries executable.
ruby-1.9.3-p545 - #downloading rubygems-2.2.2
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  404k  100  404k    0     0  25393      0  0:00:16  0:00:16 --:--:--  335k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-1.9.3-p545 - #extracting rubygems-2.2.2.
ruby-1.9.3-p545 - #removing old rubygems.
ruby-1.9.3-p545 - #installing rubygems-2.2.2...............
ruby-1.9.3-p545 - #gemset created /usr/local/rvm/gems/[email protected]
ruby-1.9.3-p545 - #importing gemset /usr/local/rvm/gemsets/global.gems.....
ruby-1.9.3-p545 - #generating global wrappers.
ruby-1.9.3-p545 - #gemset created /usr/local/rvm/gems/ruby-1.9.3-p545
ruby-1.9.3-p545 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-1.9.3-p545 - #generating default wrappers.
ruby-1.9.3-p545 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-1.9.3-p545 - #complete
WARNING: Please be aware that you just installed a ruby that is no longer maintained (2014-02-23), for a list of maintained rubies visit:

    http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering

Please consider upgrading to ruby-2.1.1 which will have all of the latest security patches.
Ruby was built without documentation, to build it run: rvm docs generate-ri

ステップ6:別のバージョンをインストールする(必要な場合)

複数のバージョンのrubyを使用する場合は、rvmを使用してインストールすることもできます。それ以外の場合は、この手順をスキップしてください。

# rvm install 1.8.6

ステップ7:デフォルトのRubyバージョンを設定する

rvmコマンドを使用して、アプリケーションで使用されるデフォルトのrubyバージョンを設定します。

# rvm use 1.9.3 --default 

Using /usr/local/rvm/gems/ruby-1.9.3-p545
ステップ8:現在のRubyバージョンを確認する

次のコマンドを使用して、現在のルビーバージョンが使用されていることを確認できます。

# ruby --version

ruby 1.9.3p545 (2014-02-24 revision 45159) [i686-linux]

上記の手順が、RVMを使用して複数のRubyバージョンをインストールするのに役立つことを願っています。


Cent OS
  1. CentOS8にRubyonRailsをインストールする方法

  2. CentOS 6 /RHEL6にMongoDB4.2/4.0をインストールする方法

  3. RVMを使用してCentOSおよびRHEL6にRuby2.0.0をインストールする方法

  1. CentOS7に最新バージョンのPython3をインストールする方法

  2. RHEL 8 /CentOS8にrubyをインストールする方法

  3. CentOSVPSにMongoDBをインストールします

  1. CentOS7にRubyをインストールする方法

  2. CentOS7にMongoDBをインストールする方法

  3. CentOS7にGitをインストールする方法