1.Redis 服务安装
Ubuntu
apt-get install redis-server
redis-cli 终端下启动命令
2.phpredis 扩展安装
扩展下载地址为:https://github.com/nicolasff/phpredis
git clone https://github.com/nicolasff/phpredis
cd phpredis
phpize
./configure --with-php-config=/usr/bin/php-config
make&&make install
终端显示Installing shared extensions: /usr/lib/php/20151012/
修改php.ini文件
有两个PHP .INI 都需要修改 cli fpm
extension_dir=/usr/lib/php/20151012/
extension=redis.so
完成后重启测试
<?php
$redis=newRedis();
$redis->connect('127.0.0.1',6379);
$redis->set("name","lyl");
echo $redis->keys("name");
?>