2、解压
tar zxvf redis-2.2.5.tgz
3、进入安装目录
cd redis-2.2.5
4、用phpize生成configure配置文件
/usr/local/php/bin/phpize
5、配置(填写php的配置文件路径)
./configure --with-php-config=/usr/local/php/bin/php-config
6、编译
make
7、安装
make install
安装完成之后,出现下面的安装路径
/usr/local/php-5.5.30/lib/php/extensions/no-debug-non-zts-20121212/
ls一下,可以看到.so的文件
然后组装一下地址:
/usr/local/php-5.5.30/lib/php/extensions/no-debug-non-zts-20121212/redis.so
8、配置php支持
vi /usr/local/php/etc/php.ini
添加
extension=/usr/local/php-5.5.30/lib/php/extensions/no-debug-non-zts-20121212/redis.so
9、开启php、redis、nginx
10、测试
$redis=new Redis();
$redis->connect("192.168.1.128",6379);
$redis->set("username","zhangsan");
echo $redis->get("user:userid:10:username");
$redis->lpush("list","helloWorld");
$redis->lpush("list","goodMorning");
$redis->lpush("list","what");
$list=$redis->lrange("list",0,-1);
print_r($list);
测试正常