使用rbenv安装并管理ruby环境
安装系统依赖库
yum update;
yum install -y epel-release git openssl-devel readline-devel zlib-devel libxml2-devel libxslt-devel libvirt-devel tar gcc-c++ pcre-devel unzip;
安装rbenv
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv;
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build;
#替换源
git clone https://github.com/andorchen/rbenv-china-mirror.git ~/.rbenv/plugins/rbenv-china-mirror
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc;
echo 'eval "$(rbenv init -)"' >> ~/.bashrc;
echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc;
source ~/.bashrc;
rbenv安装ruby
rbenv install 2.4.2;
#全局设置ruby版本
rbenv global 2.4.2;
#替换gem源
gem source -r https://rubygems.org/;
gem source -a https://gems.ruby-china.com;