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