集群php应用环境使用memcached做session同步

软件下载
wget http://memcached.googlecode.com/files/memcached-1.4.10.tar.gz
软件安装
./configure –prefix=/usr/local/memcached –disable-docs –enable-64bit
make -j 4
make install
启动服务端(默认监听tcp及udp 11211端口)
/usr/local/memcached/bin/memcached -u nobody -d

Web服务器上使用
安装Memcache的PHP扩展
http://pecl.php.net/package/memcache 选择相应想要下载的memcache版本。
安装PHP的memcache扩展
tar vxzf memcache-2.2.1.tgz
cd memcache-2.2.1
/usr/local/php/bin/phpize
./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir
make
make install
上述安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
php.ini中加入
[memcache]
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/”
extension = “memcache.so”

修改php.ini将session.savehandler=files 改成
session.save
handler = memcache
session.save_path = “tcp://10.0.0.2:11211″
重加载php即可