安装ruby(redis集群需要)

安装ruby
1.下载编译安装
[root@localhost soft]# wget http://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz
[root@localhost soft]# tar zxvf  ruby-2.4.1.tar.gz
[root@localhost soft]# cd ruby-2.4.1
[root@localhost ruby-2.4.1]# ./configure  --prefix=/opt/ruby
[root@localhost ruby-2.4.1]# make && make install

2.设置环境变量
vi /etc/profile
在最后加上
PATH=/opt/ruby/bin:$PATH
export PATH
然后执行命令
source /etc/profile

[root@localhost ~]# ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
[root@localhost ~]#

 

 



安装rubygem redis依赖
~]# wget http://rubygems.org/downloads/redis-3.3.0.gem
~]# gem install -l redis-3.3.0.gem

 

####################安装ruby2.5和redis-3.3.0.gem#############################

1.安装ruby

[root@localhost soft]# wget http://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.gz
[root@localhost soft]# tar -xvf ruby-2.5.0.tar.gz
[root@localhost soft]# cd ruby-2.5.0
[root@localhost soft]# ./configure --prefix=/opt/ruby
[root@localhost soft]# make && make install

 

 

2.设置环境变量
vi /etc/profile
在最后加上
PATH=/opt/ruby/bin:$PATH
export PATH
然后执行命令
source /etc/profile

 

[root@localhost soft]# ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]

 

 

 

3.安装redis-3.3.0.gem

[root@localhost soft]# gem install -l redis-3.3.0.gem
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass


解决办法是:
yum -y install zlib-devel
进入ruby源码文件夹,安装ruby自身提供的zlib包
[root@localhost zlib]# cd /soft/ruby-2.5.0/ext/zlib
[root@localhost zlib]# ruby ./extconf.rb
[root@localhost zlib]# make
make: *** No rule to make target `/include/ruby.h', needed by `zlib.o'. Stop.
[root@localhost zlib]# make install
make: *** No rule to make target `/include/ruby.h', needed by `zlib.o'. Stop.

 

解决办法:
vi /soft/ruby-2.5.0/ext/zlib/Makefile
#zlib.o: $(top_srcdir)/include/ruby.h #把这一行替换成下面一行
zlib.o: ../../include/ruby.h

继续:
[root@localhost zlib]# make
compiling zlib.c
linking shared-object zlib.so
[root@localhost zlib]# make install
/usr/bin/install -c -m 0755 zlib.so /opt/ruby/lib/ruby/site_ruby/2.5.0/x86_64-linux

 

重新安装
[root@localhost /]# cd soft
[root@localhost soft]# gem install -l redis-3.3.0.gem
Successfully installed redis-3.3.0
Parsing documentation for redis-3.3.0
Installing ri documentation for redis-3.3.0
Done installing documentation for redis after 0 seconds
1 gem installed

 

 

说明:

openEuler默认已经安装了ruby3版本的了

.检查ruby

[root@19c ruby-2.5.0]# ruby -v
ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]

 

 

2.安装redis-3.3.0.gem
检查redis-3.3.0.gem


[root@19c soft]# gem install -l redis-3.3.0.gem
Successfully installed redis-3.3.0
Parsing documentation for redis-3.3.0
Installing ri documentation for redis-3.3.0
Done installing documentation for redis after 2 seconds
1 gem installed

 

posted @ 2021-05-06 10:36  slnngk  阅读(135)  评论(0编辑  收藏  举报