LoginSignup
767
725

More than 5 years have passed since last update.

rbenv を使って ruby をインストールする(CentOS編)

Last updated at Posted at 2013-11-22

1. git が入っていなかったらインストール

$ sudo yum -y install git

2. rbenv をインストール(clone)する

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

3. 環境設定

# PATH に追加
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

# .bash_profile に追加
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

# 上記設定の再読み込み
$ exec $SHELL -l

4. rbenvの確認

$ rbenv --version
rbenv 0.4.0-74-g95a039a

5. ruby-build を インストール(clone)する

$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

6. ruby の最新版を確認

install -- list でインストール可能なバージョン一覧が出力される

$ rbenv install --list
Available versions:
  1.8.6-p383
  1.8.6-p420
  1.8.7-p249
   :
   :
  2.0.0-p195
  2.0.0-p247
  2.0.0-p353       ← こいつが2.0系の最新版っぽい      
  2.0.0-preview1
  :

7. ruby のインストール

先ほど調べたバージョンを指定する

$ rbenv install -v 2.0.0-p353

8. 環境確認

再読み込み

$ rbenv rehash

インストールされているruby一覧を確認

$ rbenv versions
* system (set by /home/vagrant/.rbenv/version)
  2.0.0-p353

先ほどインストールした最新版に設定

$ rbenv global 2.0.0-p353

確認

$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]

おしまい。

767
725
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
767
725