memcached是一款缓存软件,他是基于C/S模式架构的软件
首先需要搭建好LAMP,LNMP环境
服务端需要安装memcached守护进程,客户端则需要启用memcache进程
服务端安装的软件:
tar -zxvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local/libevent
make
make install
cd ..
tar -zxvf memcached-1.4.13.tar.gz
cd memcached-1.4.13
./configure --prefix=/usr/local/memcached
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/
echo $?
make
make install
echo "/usr/local/lib" >>/etc/ld.so.conf
ldconfig
which memcached
/usr/local/memcached/bin/memcached -p 11211 -u root -m 16m -c 10240 -d
lsof -i :11211
pkill memcached
lsof -i :11211
/usr/local/memcached/bin/memcached -p 11211 -u root -m 16m -c 10240 -d
lsof -i :11211
iptables -L
客户端安装的软件:
tar -zxvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local/libevent
make && make install
cd ..
tar -zxvf memcache-2.2.5.tgz
cd memcache-2.2.5
/application/php/bin/phpize
./configure --enable-memcache --with-php-config=/application/php/bin/php-config --with-zlib-dir
make
make install
ll /application/php5.3.27/lib/php/extensions/no-debug-non-zts-20090626/
vim /application/php/etc/php.ini
killall php-fpm
killall nginx
/application/nginx/sbin/nginx
/application/php/sbin/php-fpm
cd /application/nginx/html/
vim index.php
vim ../conf/nginx.conf
/application/nginx/sbin/nginx -s reload
cd /application/php/etc/
mv php.ini /application/php/lib/
cd /application/php/lib/
vim php.ini 客户端需要更改的四个配置
####session.save_handler = memcached
####session.save_path = "tcp://172.16.1.219:11211"
####extension_dir = "/application/php5.3.27/lib/php/extensions/no-debug-non-zts-20090626/"
####extension = memcache.so
killall php-fpm
/application/php/sbin/php-fpm
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx -s reload
附件:http://down.51cto.com/data/2365735
本文转自陈继松 51CTO博客,原文链接:http://blog.51cto.com/chenjisong/1655839,如需转载请自行联系原作者