1.安裝libevent (依賴包,不裝回報(bào)錯(cuò))
shell> wget http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz
#后面版本號(hào)隨意
shell> tar zxf libevent-2.0.12-stable.tar.gz
shell> cd libevent-2.0.12-stable
shell>./configure --prefix=/usr/local/lib
shell> make && make install
2.安裝Memcached(服務(wù)器端源碼包)
shell> wget http://memcached.org/files/memcached-1.5.0.tar.gz
shell> cd memcached-1.5.0
shell>./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/lib
shell> make && make install
啟用memcached
shell > /usr/local/memcached/bin/memcached -u root -d
常用啟動(dòng)參數(shù)如下:
-m:最大使用內(nèi)存,以MB為單位痢掠,默認(rèn)64应媚。
-p:進(jìn)程所使用的TCP進(jìn)程端口汗销,默認(rèn)11211晴裹。
-d:將memcached作為后臺(tái)守護(hù)進(jìn)程運(yùn)行脉漏。
-u:?jiǎn)?dòng)用戶锈麸。
-P:進(jìn)程文件存放路徑讼育。
-c:最大運(yùn)行并發(fā)數(shù),默認(rèn)1024啥供。
-l:監(jiān)聽(tīng)服務(wù)地址(即允許telnte登錄的IP)悯恍。
用ps -A|grep memcache
指令可以查看是否開(kāi)啟
3.安裝php-memcache擴(kuò)展
shell>weget http://pecl.php.net/get/memcache-3.0.6.tgz
shell>tar -zxvf memcache-3.0.6.tgz
shell>cd memcache-3.0.6
shell>/usr/local/bin/phpize
shell>./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
shell>make && make install
php文件夾中會(huì)出現(xiàn)memcache.so擴(kuò)展文件
/usr/local/php/lib/php/extensions/no-debug-zts-20131226/memcache.so
在php.ini中添加
extension=memcache.so
重啟apache
phpinfo.php