下載下傳源碼包:
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:
[[email protected]_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:
[[email protected]_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
[[email protected]_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/
執行指令:
[[email protected]_0_15_centos openssl]# ruby ./extconf.rb
若出現以下資訊:
[[email protected]_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,安裝即可.
繼續執行指令
[[email protected]_0_15_centos openssl]# make
若出現錯誤資訊:
make: *** No rule to make target `/include/ruby.h', needed by `ossl_x509attr.o'. Stop.
則需要編輯 生成的 Makefile 檔案,打開該檔案,增加 top_srcdir = ../.. 即可。
[[email protected]_0_15_centos openssl]# make install
[[email protected]_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
[[email protected]_0_15_centos openssl]#
完
--------------------------------------------------------------------------