LoginSignup
123

More than 5 years have passed since last update.

CentOSでrbenvをシステムにインストールする

Last updated at Posted at 2014-03-09

rbenvのよくあるインストール手順はユーザのホームディレクトリに入れるパターンが多いですが、複数ユーザで共有したかったのでシステムにインストールしてみることにしました。ここでは /usr/local/rbenv にインストールするものとして説明します。別の場所にインストールする場合は適宜よみかえてください。以下その手順です。

まずビルドに必要なパッケージを導入します。

# yum install -y git gcc gcc-c++ openssl-devel readline-devel

次にソースをとってきます。下記の例では /usr/local にインストールすることにします。

# cd /usr/local
# git clone git://github.com/sstephenson/rbenv.git rbenv
# git clone git://github.com/sstephenson/ruby-build.git rbenv/plugins/ruby-build

ぼくの環境のCentOS 6.5では、全ユーザの .bashrc の中で /etc/profile.d/ 配下がロードされるようになっていました。なので、PATHの設定を全ユーザに反映させるため、 /etc/profile.d/rbenv.sh とかを作成し下記のように書きます。 --no-rehash をつけないとログインのたび rehash するので遅くなるようです。

/etc/profile.d/rbenv.sh
export RBENV_ROOT="/usr/local/rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init --no-rehash -)"

上記をロードします。

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

Rubyは下記のようにrootでインストールします。gemは、システムにはbundlerだけ入れておいてあとはpathを指定して管理するのがよいでしょう。

# rbenv install 2.1.0
# gem install bundler --no-ri --no-rdoc

参考文献

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
123