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

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

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

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

ルビー は動的なオブジェクト指向プログラミング言語です。RVMはRubyVersionManagerの略で、LinuxプラットフォームへのRubyのインストールを容易にします。 RVMは、競合することなく複数のバージョンのRubyを管理するのにも役立ち、単一のコマンドを使用してシステムを任意のバージョンのRubyに切り替えることができます。

この記事は、Ruby2.0.0をインストールする方法に役立ちます。 CentOSでは、RVMを使用するRedHatシステム。他のバージョンのRubyをインストールするには、次のリンクを使用してください

ステップ1:必要なパッケージをインストールする

まず、次のコマンドを使用して、rubyのインストールに必要なすべてのパッケージをシステムにインストールする必要があります。

# 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
ステップ2:RVM(Rubyバージョンマネージャー)をインストールする

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

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

次に、Rubyをインストールする前にシステム環境をセットアップします。以下のコマンドを使用して、rvm環境をセットアップします。

# source /etc/profile.d/rvm.sh
ステップ3:Rubyをインストールする

RVM環境のセットアップが完了したら、次のコマンドを使用してRuby言語をインストールします。

# rvm install 2.0.0

[サンプル出力]

Searching for binary rubies, this might take some time.
No binary rubies available for: centos/6/i386/ruby-2.0.0-p451.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.0.0-p451, this may take a while depending on your cpu(s)...
ruby-2.0.0-p451 - #downloading ruby-2.0.0-p451, this may take a while depending on your connection...
** Resuming transfer from byte position 24576
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10.2M  100 10.2M    0     0   188k      0  0:00:55  0:00:55 --:--:--  414k
ruby-2.0.0-p451 - #extracting ruby-2.0.0-p451 to /usr/local/rvm/src/ruby-2.0.0-p451...
ruby-2.0.0-p451 - #applying patch /usr/local/rvm/patches/ruby/changeset_r45225.diff.
ruby-2.0.0-p451 - #applying patch /usr/local/rvm/patches/ruby/changeset_r45240.diff.
ruby-2.0.0-p451 - #applying patch /usr/local/rvm/patches/ruby/ssl_no_ec2m.patch.
ruby-2.0.0-p451 - #configuring..................................................
ruby-2.0.0-p451 - #post-configuration.
ruby-2.0.0-p451 - #compiling............................................................................
ruby-2.0.0-p451 - #installing.............................
ruby-2.0.0-p451 - #making binaries executable..
ruby-2.0.0-p451 - #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  96653      0  0:00:04  0:00:04 --:--:--  136k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.0.0-p451 - #extracting rubygems-2.2.2...
ruby-2.0.0-p451 - #removing old rubygems.........
ruby-2.0.0-p451 - #installing rubygems-2.2.2...............
ruby-2.0.0-p451 - #gemset created /usr/local/rvm/gems/[email protected]
ruby-2.0.0-p451 - #importing gemset /usr/local/rvm/gemsets/global.gems.....................................
ruby-2.0.0-p451 - #generating global wrappers.........
ruby-2.0.0-p451 - #gemset created /usr/local/rvm/gems/ruby-2.0.0-p451
ruby-2.0.0-p451 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.0.0-p451 - #generating default wrappers.........
ruby-2.0.0-p451 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.0.0-p451 - #complete
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on an up to date linux system.
This may have known and unaccounted for security vulnerabilities.
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

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

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

# rvm use 2.0.0 --default

Using /usr/local/rvm/gems/ruby-2.0.0-p451

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

# ruby --version

ruby 2.0.0p451 (2014-02-24 revision 45167) [i686-linux]

おめでとうございます。システムにRubyが正常にインストールされました。次の記事を読んで、RubyをApacheWebサーバーと簡単な手順で統合します。

参照:
1. http://rvm.io/rubies/installing


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

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

  3. CentOS /RHEL8にRubyをインストールする方法

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

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

  3. RHEL 8 /CentOS8にntfs-3gをインストールする方法

  1. PHP-mbstringをRHEL8/CentOS8にインストールする方法

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

  3. DropboxをRHEL8/CentOS8にインストールする方法