微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP Redis扩展无法加载的问题解决方法

最近在工作中需要使用PHP访问Redis,从https://github.com/phpredis/phpredis下载了PHPredis,并且按照官方的说明进行了安装

PHPize
./configure [--enable-redis-igbinary]
make && make install

但是在重启PHP-fpm的过程中,发生了如下的错误,redis.so无法载入

[root@brand009 modules]# /usr/sbin/PHP-fpm
/usr/sbin/PHP-fpm: /usr/lib64/libssl.so.10: no version information available (required by /usr/sbin/PHP-fpm)
/usr/sbin/PHP-fpm: /usr/lib64/libcrypto.so.10: no version information available (required by /usr/sbin/PHP-fpm)
/usr/sbin/PHP-fpm: /usr/lib64/libcrypto.so.10: no version information available (required by /usr/sbin/PHP-fpm)
[29-Jun-2015 11:14:43] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/PHP/modules/redis.so' - /usr/lib64/PHP/modules/redis.so: undefined symbol: zend_new_interned_string in UnkNown on line 0
<br />
<b>Warning</b>: PHP Startup: Unable to load dynamic library '/usr/lib64/PHP/modules/redis.so' - /usr/lib64/PHP/modules/redis.so: undefined symbol: zend_new_interned_string in <b>UnkNown</b> on line <b>0</b><br />
<br />

试了网上一些解决方案,均无法解决问题。

实在没别的办法,于是打算重装PHP-fpm试试,遂去http://php-fpm.org/download/想下载个新版本的PHP-fpm,结果发现版本大于5.3.3的PHP内部已经集成了PHP-fpm,不用再另行安装了。

PHP Redis扩展无法加载的问题解决方法


于是用PHP --version查询了一下PHP的版本,已经是5.6.6了,

PHP --version
PHP 5.6.6 (cli) (built: Mar 9 2015 13:27:38)
copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0,copyright (c) 1998-2015 Zend Technologies

突然恍然大悟,自己一直用的是安装在另一个目录的PHP-fpm,和PHP并不是配套的

查看这个PHP-fpm的版本,发现是5.3.3

$/usr/sbin/PHP-fpm -v
PHP 5.3.3 (fpm-fcgi) (built: Oct 30 2014 20:14:56)
copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0,copyright (c) 1998-2010 Zend Technologies

PHP内部集成的PHP-fpm版本是5.6.6

$ /usr/local/PHP/sbin/PHP-fpm -v
PHP 5.6.6 (fpm-fcgi) (built: Mar 9 2015 13:27:55)
copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0,copyright (c) 1998-2015 Zend Technologies

PHP内部集成的PHP-fpm重启,成功!

root   18442   1 0 17:36 ?    00:00:01 PHP-fpm: master process (/usr/local/PHP/etc/PHP-fpm.conf)
nobody  30640 18442 0 18:04 ?    00:00:02 PHP-fpm: pool www
nobody  31156 18442 0 18:05 ?    00:00:02 PHP-fpm: pool www
nobody  32424 18442 0 18:08 ?    00:00:02 PHP-fpm: pool www

所以粗心害死人啊,以后在安装程序的时候需要多加小心,尽量显式的标明软件的版本,这样就会少犯这样的错误,少走弯路了。

另外需要注意:

PHP.ini中一定要配置extension_dir和extension,如:

extension_dir = "/usr/lib64/PHP/modules/"
extension=redis.so

PHPredis编译出来的redis.so也需要拷贝到"/usr/lib64/PHP/modules/"中

"/etc/PHP.d/"中也要软连接redis.so,并且要创建一个redis.ini文件内容如下:

$ cat /etc/PHP.d/redis.ini
; Enable redis extension module
extension=redis.so

安装PHPredis还可以通过命令

pecl install redis

以上就是本次介绍的全部知识点内容,感谢大家的阅读和对我们的支持

原文地址:https://www.jb51.cc/php/525919.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐