用rbenv給整個系統安裝ruby(所有使用者都可用)

baibaluo發表於2015-12-08
rbenv非常好用,但有一個小問題,每個使用者都需要單獨安裝和設定版本。
下面安裝步驟可以安裝在/usr/local/rbenv下,所有使用者都可以共享rbenv。
 
#rbenv安裝(/usr/local/rbenv)
#安裝依賴,需要root使用者
yum install -y git
yum install -y readline-devel
yum install -y openssl-devel zlib-devel
yum install -y postgresql-devel
#關閉ssl驗證,如果clone報ca錯誤,執行下面的即可
#git config --global http.sslVerify false
git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
echo 'export RBENV_ROOT=/usr/local/rbenv'>/etc/profile.d/rbenv.sh
echo 'export PATH="$RBENV_ROOT/bin:$PATH"'>>/etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"'>>/etc/profile.d/rbenv.sh
git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
#重新載入profile
source ~/.bash_profile
#檢視可用ruby版本
rbenv install --list
#安裝某一版本
rbenv install 2.1.5
rbenv global 2.1.5
#使用國內gem源
gem sources --remove https://rubygems.org/
#gem sources -a http://ruby.sdutlinux.org/
gem sources -a https://ruby.taobao.org/
gem sources -l
gem install bundle -V

相關文章