1、安装
wget https://codeload.github.com/phpredis/phpredis/zip/develop -o phpredis.zip
mv develop phpredis.zip
unzip phpredis.zip
cd phpredis-develop
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
2、配置vim /usr/local/php/php.ini // 增加一行extension = redis.so
/usr/local/php/bin/php -m |grep redis 检查是否成功
php redis中文文档http://www.cnblogs.com/weafer/archive/2011/09/21/2184059.html
3、三层共享
php.ini中加入
session.save_handler = "redis"
session.save_path = "tcp://127.0.0.1:6379"
或者apache虚拟主机加入
php_value session.save_handler " redis" php_value session.save_path " tcp://127.0.0.1:6379"
或者php-fpm.conf对应的pool中加入
php_value[session.save_handler] = redis
php_value[session.save_path] = " tcp://127.0.0.1:6379 "
4、检测
wget http://study.lishiming.net/.mem_se.txt
mv .mem_se.txt /usr/local/apache2/htdocs/session.php
curl localhost/session.php
输出类似于 1443710814<br><br>1443710814<br><br>9jm6nom9ogojedj3pth0iscv22
#如果出现500的错误需要编辑/usr/local/php/etc/php.ini
#display_error去掉前面的#打开错误日志开关,然后查看错误日志
连接redis
/usr/local/redis/bin/redis-cli
127.0.0.1:6379> keys * //可以把所有的key都列出来
"PHPREDIS_SESSION:9jm6nom9ogojedj3pth0iscv22"
127.0.0.1:6379> get PHPREDIS_SESSION:9jm6nom9ogojedj3pth0iscv22
"TEST|i:1443710814;TEST3|i:1443710814;"
本文出自 “愺艮搥豩” 博客,谢绝转载!
原文地址:http://riverxyz.blog.51cto.com/533303/1825236