44
42

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS 6.3にシステムワイドなrbenv+ruby-buildの環境を構築する手順

Last updated at Posted at 2012-12-26

1. rbenvとruby-buildのインストール

全てのユーザで共有したいのでrbenvを/usr/localにインストールする。rootで作業する。

# cd /usr/local
# git clone git://github.com/sstephenson/rbenv.git rbenv 
# mkdir rbenv/shims rbenv/versions
# groupadd rbenv
# chgrp -R rbenv rbenv
# chmod -R g+rwxXs rbenv
# git clone git://github.com/sstephenson/ruby-build.git ruby-build
# cd ruby-build
# ./install.sh 

2. 環境変数の設定

rbenvとruby-buildを全ユーザで利用するために環境変数を設定する。
けれども、どこで、どのように設定するかが悩む。
今回は/etc/profile.d下に環境変数を設定するshell scriptを作成する方法をとる。

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

3. sudo時に環境変数のPATHを引き継ぐ設定をする

# visudo

を実行し、

Defaults    env_reset
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults    env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

Defaults    env_keep += "PATH"

を追記する。

インストールは個々までで完了。
あとは再ログインしてrbenv install --listとかで確認すればOK.

44
42
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
44
42

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?