centos 虽然内置了 ruby ,可以通过yum 进行安装,但是版本相对较低。
这里附上编译安装步骤:
一、下载Ruby源码包
wget ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.7.tar.gz
二、解压安装Ruby
tar zxvf ruby-2.1.7.tar.gz ./configure --disable-install-rdoc make make prefix=/usr/local install
三、安装Bundler Gem
$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ $ gem sources -l https://gems.ruby-china.org # 确保只有 gems.ruby-china.org
gem install bundler --no-doc
bundle config mirror.https://rubygems.org https://gems.ruby-china.org
添加以下软连接,否则可能提示找不到
ln -s /usr/local/bin/ruby /usr/bin/ruby ln -s /usr/local/bin/gem /usr/bin/gem ln -s /usr/local/bin/bundle /usr/bin/bundle
四、查看验证
which ruby
which gem
which bundle
ruby -v
转载请注明:苏demo的别样人生 » centos 安装ruby