PHP安装redis扩展

释放双眼,带上耳机,听听看~!

环境如下:

PHP安装redis扩展

安装步骤:

1.下载并解压缩redis-3.1.4.tgz:


1
2
3
4
1# wget https://pecl.php.net/get/redis-3.1.4.tgz --no-check-certificate
2# chmod 777 redis-3.1.4.tgz
3# tar zxvf redis-3.1.4.tgz
4

2.进入解压缩之后的目录,进行安装:


1
2
3
4
5
6
7
8
9
10
1# phpize
2Configuring for:
3PHP Api Version:         20131106
4Zend Module Api No:      20131226
5Zend Extension Api No:   220131226
6# ./configure
7# make
8# make install
9Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20131226/
10

3.修改php.ini文件,并重启php-fpm或者apache。本次使用的apache作为web服务器,所以重启httpd服务:

# vim /usr/local/lib/php.ini

增加如下内容:


1
2
3
4
1extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20131226"
2
3extension=redis.so
4

 最后,redis扩展已经成功安装:

PHP安装redis扩展

注意事项:

注意php-redis扩展包需要和php版本兼容。如果php版本较旧,不要使用最新php-redis扩展包。本次安装redis-5.0.0.tgz的扩展包就失败了,make编译时,会报如下错误:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1...
2In file included from /usr/local/src/redis-5.0.0/redis.c:27:
3/usr/local/src/redis-5.0.0/common.h:12:28: error: zend_smart_str.h: No such file or directory
4/usr/local/src/redis-5.0.0/common.h:13:43: error: ext/standard/php_smart_string.h: No such file or directory
5...
6/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘pipeline_cmd’
7/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘pipeline_cmd’
8/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘mode’
9/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘mode’
10/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘current’
11/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘current’
12/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘current’
13/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘head’
14/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘head’
15/usr/local/src/redis-5.0.0/redis.c:1019: error: ‘RedisSock’ has no member named ‘current’
16...
17

 

 

给TA打赏
共{{data.count}}人
人已打赏
安全运维

OpenSSH-8.7p1离线升级修复安全漏洞

2021-10-23 10:13:25

安全运维

设计模式的设计原则

2021-12-12 17:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索