1、首先要安装两个依赖项
#apt-get install zlib1g zlib1g-dev #apt-get install libssl libssl-dev
2、然后下载Ruby源码
https://www.ruby-lang.org/en/
./configure --prefix=usr/ruby/ruby_2.2.3 make make install
3、配置环境变量
编辑/etc/profile
export RUBY_HOME=/usr/ruby/ruby_2.2.3 export RUBYLIB=$RUBY_HOME/lib/ruby/2.2.0:$RUBY_HOME/lib/ruby/2.2.0/x86_64-linux:$RUBY_HOME/share/ri/2.2.0:$RUBYLIB export PATH=$RUBY_HOME/bin:$PATH
更新环境变量
source /etc/profile
4、切换为国内源
gem sources --add https://ruby.taobao.org/ gem sources --remove https://rubygems.org/ gem sources -l
5、安装rails
$ gem install rails