下载源码包:
https://cache.ruby-china.org/pub/ruby/ruby-2.3.1.tar.gz
解压 :
tar -zxvf ruby-2.3.1.tar.gz
进入目录 ruby-2.3.1
./configure --prefix=/usr/local/ruby-2.3.1
编译 安装(make && make install)
创建连接文件
ln -s /usr/local/ruby-2.3.1/bin/ruby /usr/bin/ruby
测试
ruby -v
上边一气呵成...
------------------------------------
gem install redis
报错信息1:
[root@VM_0_15_centos bin]# gem install redis
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
错误1解决方案:
cd /ruby-2.3.1源码目录/ext/zlib
执行命令:
ruby ./extconf.rb
make
make install
报错信息1.1:
checking for deflateReset() in -lz... no
checking for deflateReset() in -llibz... no
checking for deflateReset() in -lzlib1... no
checking for deflateReset() in -lzlib... no
checking for deflateReset() in -lzdll... no
checking for deflateReset() in -lzlibwapi... no
出现该信息是缺少依赖导致: 安装 zlib-devel,重新执行解决方案1的步骤.
--------
报错信息2:
[root@VM_0_15_centos zlib]# gem install redis
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
[root@VM_0_15_centos zlib]# yum install openssl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package 1:openssl-1.0.2k-8.el7.x86_64 already installed and latest version
Nothing to do
错误2解决方案:
cd /ruby-2.3.1源码目录/ext /openssl/
执行命令:
[root@VM_0_15_centos openssl]# ruby ./extconf.rb
若出现以下信息:
[root@VM_0_15_centos openssl]# ruby ./extconf.rb
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
checking for openssl/ssl.h... no
则是缺少 依赖包 openssl-devel,安装即可.
继续执行命令
[root@VM_0_15_centos openssl]# make
若出现错误信息:
make: *** No rule to make target `/include/ruby.h', needed by `ossl_x509attr.o'. Stop.
则需要编辑 生成的 Makefile 文件,打开该文件,增加 top_srcdir = ../.. 即可。
[root@VM_0_15_centos openssl]# make install
[root@VM_0_15_centos openssl]# gem install redis
Fetching: redis-4.0.1.gem (100%)
Successfully installed redis-4.0.1
Parsing documentation for redis-4.0.1
Installing ri documentation for redis-4.0.1
Done installing documentation for redis after 1 seconds
1 gem installed
[root@VM_0_15_centos openssl]#
完
--------------------------------------------------------------------------