1. 下载session存储脚本:[root@hao-01 ~]# wget http://study.lishiming.net/.mem_se.txt
2. 进入[root@hao-01 ~]# cd /data/wwwroot/test/
3. 移动session存储脚本,并重命名为php格式脚本:[root@hao-01 test.com]# mv /root/.mem_se.txt 1.php
4. curl访问1.php:[root@hao-01 test.com]# curl localhost/1.php
5. 查看tmp下有没有sess_格式的文件:[root@hao-01 test.com]# ls -lt /tmp/
6. 编辑php-ini:[root@hao-01 test.com]# vim /usr/local/php-fpm/etc/php-ini
注释掉这行:;session.save_handler = files #添加以下:
session.save_handler = memcache
session.save_path="tcp://192.168.0.9:11211"
本实例是在lamp/lnmp环境下实现(下面哪种没问题,就用哪种)
1. 编辑php.ini添加两行
session.save_handler = memcache
session.save_path = "tcp://192.168.0.9:11211"
2. 或者httpd.conf中对应的虚拟主机中添加
php_value session.save_handler "memcache"
php_value session.save_path "tcp://192.168.0.9:11211"
3. 或者php-fpm.conf对应的pool中添加
php_value[session.save_handler] = memcache
php_value[session.save_path] = " tcp://192.168.0.9:11211 "
7. curl访问1.php:
[root@hao-01 test.com]# curl localhost/1.php