1、下载Ruby源码 wget http://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.gz 2、解压 tar xzvf ruby-2.5.8.tar.gz 3、进入ruby-2.5.8 目录 4、安装 mkdir /usr/local/ruby ./config -prefix=/usr/local/ruby make && make install 5、/etc/profile后加入 export PATH=/usr/local/ruby/bin:$PATH souce /etc/profile 错误undefined method `invoke_with_build_args' for nil:NilClass 解决 错误No rule to make target `/include/ruby.h', needed by `zlib.o'. Stop. 解决 vi /usr/local/ruby-2.5.8/ext/zlib/Makefile #zlib.o: $(top_srcdir)/include/ruby.h #把这一行替换成下面一行 yum install zlib-devel zlib.o: ../../include/ruby.h /usr/local/ruby-2.5.8/ext/zlib/ruby ./extconf.rb make && make install /usr/local/ruby-2.5.8/ext/openssl/ruby ./extconf.rb make && make install