Centos7 下安装PHP7 phpredis扩展报错解决办法

php7编译安装phpredis扩展报一下错误的解决办法

hecking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
[root@iZ236oj5mp5Z phpredis-master]# make && make install
/bin/sh /usr/local/src/redis-stable/phpredis-master/libtool --mode=compile cc -I. -I/usr/local/src/redis-stable/phpredis-master -DPHP_ATOM_INC -I/usr/local/src/redis-stable/phpredis-master/include -I/usr/local/src/redis-stable/phpredis-master/main -I/usr/local/src/redis-stable/phpredis-master -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/redis-stable/phpredis-master/redis.c -o redis.lo
mkdir .libs
cc -I. -I/usr/local/src/redis-stable/phpredis-master -DPHP_ATOM_INC -I/usr/local/src/redis-stable/phpredis-master/include -I/usr/local/src/redis-stable/phpredis-master/main -I/usr/local/src/redis-stable/phpredis-master -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/redis-stable/phpredis-master/redis.c -fPIC -DPIC -o .libs/redis.o
In file included from /usr/local/src/redis-stable/phpredis-master/redis.c:27:0:
/usr/local/src/redis-stable/phpredis-master/common.h:3:40: 致命错误:ext/standard/php_smart_str.h:没有那个文件或目录
#include <ext/standard/php_smart_str.h>
^
编译中断。
make: *** [redis.lo] 错误 1

解决办法,因为最新的 phpredis 分了几大分支,针对最新的PHP稳定发行版 php7 有专门为php7的分支,所以我们从github拉下phpredis 源码 需要切换到PHP7的分支 首先git clone phpredis下来

 

git clone https://github.com/nicolasff/phpredis

cd phpredis

git checkout php7

/usr/local/php7/bin/phpize #找不到phpize的路径可用whereis命令查看:whereis phpize 得到路径

./configure –with-php-config=/usr/local/php/bin/php-config #此处为php-config的路径,可用whereis php-config查看路径

make && make install

然后看到了等字样,就说明安装成功了

Build complete.
Don't forget to run 'make test'.

原文链接:,转发请注明来源!

发表评论