下载对应php扩展:https://pecl.php.net/package/redis
tar -zxvf redis-3.1.6.tgz cd redis-3.1.6 /application/php7/bin/phpize ./configure --with-php-config=/application/php7/bin/php-config make #编译 make install #安装 #添加扩展 vim /application/php7/lib/php.ini
php -m|grep redis
测试:
$redis = new \Redis(); $redis->connect(C('REDIS_HOST'), C('REDIS_PORT')); $redis->set('myname', 'manu'); //设置值 $res = $redis->get('myname'); echo $res;
安装phpredis
1,下载phpredis
git clone https://github.com/phpredis/phpredis.git cd phpredis
2.开始编译phpredis扩展
phpize //检查php扩展,出错的话:bash: phpize: command not found //yum install php-devel //我是安装php56u的所以:yum install php56u-devel ./configure make make install
3.安装配置phpredis扩展
检查redis.so 库文件是否存在
修改php.ini配置文件
vim /etc/php.ini extention="redis.so" //添加这一行扩展配置
本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/articles/9341684.html