安装PHP7 redis扩展:
phpredis-4.2.0.tar.gz:下载:wget https://github.com/phpredis/phpredis/archive/4.2.0.tar.gz
$ tar -zxvf phpredis-4.0.2.tar.gz
$ cd phpredis-4.0.2
$ /usr/local/php/bin/phpize
# php安装后的路径
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make && make install
#将redis.so添加到php.ini中
$ echo 'extension=redis.so' >> /usr/local/php71/lib/php.ini
或者
extension= /usr/local/php/lib/php/extensions/no-debug-zts-20160303/redis.so
测试:
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->auth('123456');
echo "Connection to server sucessfully";
//查看服务是否运行
echo "Server is running: " . $redis->ping();
问题:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
安装依赖 autoconf
$ yum -y install autoconf