centos下安装ruby

  • A+
所属分类:ruby

centos下安装ruby

1.安装一些编译时可能需要用到的工具

yum install -y readline-devel

2.安装rbenv

mkdir /usr/local/rbenv
cd /usr/local/rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv

3.安装ruby-build,用来编译安装ruby

git clone git://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

4.安装rbenv-gem-rehash,方便通过gem命令安装完gem后无需手动输入rbenv rehash命令

git clone git://github.com/sstephenson/rbenv-gem-rehash.git /usr/local/rbenv/plugins/rbenv-gem-rehash

5.安装rbenv update,用来通过rbenv update命令更新rbenv以及所有插件

git clone git://github.com/rkh/rbenv-update.git /usr/local/rbenv/plugins/rbenv-update

6.使用Ruby China的镜像安装Ruby

git clone git://github.com/AndorChen/rbenv-china-mirror.git /usr/local/rbenv/plugins/rbenv-china-mirror

7.修改环境变量

echo 'export PATH=$PATH:/usr/local/rbenv/bin'>>/etc/profile
echo 'eval "$(rbenv init -)"'>>/etc/profile

8.重载环境变量

source /etc/profile

9.使用rbenv安装Ruby

rbenv install --list #列出所有ruby版本
rbenv install 2.4.1 #安装2.4.1的ruby版本
rbenv global 2.4.1 #将当前使用版本设置为2.4.1

10.查看是否已经成功安装Ruby

ruby -v
百分购

发表评论

您必须才能发表评论!