用rbenv給整個系統安裝ruby(全部用戶均可用)

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
相關文章
相關標籤/搜索