码迷,mamicode.com
首页 > Web开发 > 详细

php中应用memcached

时间:2017-07-12 13:41:42      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:pat   应用   value   bug   memcach   测试   扩展   usr   config   

PHP连接Memcached
先安装php的memcache扩展
# wget  http://ip/data/attachment/forum/memcache-2.2.3.tgz
# tar zxf memcache-2.2.3.tgz 
# cd memcache-2.2.3
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make && make install
安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
把这个记住,然后修改php.ini,把 extension_dir = "./"
修改为extension_dir = "/usr/local/servers/php5/lib/php/extensions/no-debug-non-zts-20090626/"
并添加一行extension="memcache.so"
PHP连接Memcached 检验
/usr/local/php/bin/php -m |grep memcache
下载测试php脚本 curl ip/study_v2/.memcache.txt > 1.php 2>/dev/null /usr/local/php/bin/php 1.php
Memcached 实现session共享
本实例是在lamp/lnmp环境下实现 编辑php.ini添加两行
session.save_handler = memcache 
session.save_path = "tcp://192.168.0.9:11211" 
或者httpd.conf中对应的虚拟主机中添加
php_value session.save_handler "memcache" 
php_value session.save_path "tcp://192.168.0.9:11211" 
或者php-fpm.conf对应的pool中添加 php_value[session.save_handler] = memcache
php_value[session.save_path] = " tcp://192.168.0.9:11211 "

Memcached session测试
wget http://ip/.mem_se.txt mv .mem_se.txt
/usr/local/apache2/htdocs/session.php curl localhost/session.php
类似于1443702394<br><br>1443702394<br><br>i44nunao0g3o7vf2su0hnc5440
telnet 127.0.0.1 11211
get i44nunao0g3o7vf2su0hnc5440

php中应用memcached

标签:pat   应用   value   bug   memcach   测试   扩展   usr   config   

原文地址:http://www.cnblogs.com/ddgen/p/7154769.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!