标签: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
标签:pat 应用 value bug memcach 测试 扩展 usr config
原文地址:http://www.cnblogs.com/ddgen/p/7154769.html