redis安装配置与测试

时间:2023-12-20 13:09:20

phpredis:

https://github.com/nicolasff/phpredis

http://www.cnblogs.com/ikodota/archive/2012/03/05/php_redis_cn.html
http://redisdoc.com/

window安装:
http://windows.php.net/downloads/pecl/snaps/redis/2.2.5/

extension=php_igbinary.dll
extension=php_redis.dll

linux 安装:

下载客户端:
https://github.com/phpredis/phpredis

https://github.com/phpredis/phpredis/downloads

安装phpredis扩展模块

$ tar zxvf nicolasff-phpredis-2.2.2-48-g7dfac44.tar.gz
$ cd nicolasff-phpredis-7dfac44/
$ /usr/local/webserver/php/bin/phpize
$ ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
$ make
$ make install

  

修改php.ini

查看/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613是否有redis.so(后面日期不同)
在php.ini中 添加 extension=redis.so

重启php进程

/usr/local/webserver/php/sbin/php-fpm restart

查看phpinfo扩展

代码测试:

$redis = new Redis();
$redis->connect('127.0.0.1',6379);
$redis->set('long','Hello World');
echo $redis->get('long');