1.安装phpize
yum install php-devel
2.下载扩展源码包,直接用wget
wget https://github.com/edtechd/phpredis/archive/php7.zip
3. 解压php7.zip
unzip php7.zip
4. 解压目录为phpredis-php7,进入该文件夹,开始编译php扩展
cd pphpredis-php7 phpize
[root@iZhp37dmahkdx7kgn3gss6Z phpredis-php7]# phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
[root@iZhp37dmahkdx7kgn3gss6Z phpredis-php7]# ./configure --with-php-config=/usr/local/php/bin/php-config
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for a sed that does not truncate output… /usr/bin/sed
......
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20170718/
[root@iZhp37dmahkdx7kgn3gss6Z phpredis-php7]# cd /usr/local/php/lib/php/extensions/no-debug-zts-20170718/
[root@iZhp37dmahkdx7kgn3gss6Z no-debug-zts-20170718]# ls
opcache.a opcache.so redis.so
[root@iZhp37dmahkdx7kgn3gss6Z no-debug-zts-20170718]# ls
5. 查找php-config路径
find / -name php-config
6、配置环境
./configure --with-php-config=/www/server/php/72/bin/php-config
[root@iZhp37dmahkdx7kgn3gss6Z etc]# pkill php-fpm
7、编译安装
make && make install
8、配置php.ini,添加:
extension=redis.so
9、重启php
在php.info中查看redis信息
结束php进程:
pkill php-fpm
启动php-fpm:
[root@iZhp37dmahkdx7kgn3gss6Z php]# ./sbin/php-fpm