用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
posted @ 2015-12-08 01:14  baibaluo  阅读(694)  评论(0编辑  收藏  举报