一:Memcached安裝php
1)安裝擴展源:curl
yum install -y epel-releaseide
2)安裝相關組件:memcached
yum install -y libevent memcached libmemcached測試
3)啓動mamcached服務:url
/etc/init.d/memcached start
spa
查看是否啓動成功:blog
二:PHP鏈接Memcached get
1)先安裝php的memcache擴展
wget http://www.apelearn.com/bbs/data/p_w_upload/forum/memcache-2.2.3.tgz
# tar zxfmemcache-2.2.3.tgz
# cdmemcache-2.2.3
# /usr/bin/phpize //yum安裝的php默認會在/usr/bin/phpize下
# ./configure --with-php-config=/usr/bin/php-config //此處路徑由具體狀況而定
# make && make install
//顯示installing shared extensions 代表安裝成功,後面的路徑下會有一個memcache.so文件,能夠本身ls看一下
2)把後面這個路徑記住,而後修改php.ini,把extension_dir= "./" 修改成
extension_dir= " /usr/lib/php/modules/ "
而且添加一行:
extension="memcache.so"
3)PHP鏈接Memcached檢驗
/usr/bin/php -m |grep memcache
4)下載測試php腳本
curl www.apelearn.com/study_v2/.memcache.txt > 1.php 2>/dev/null
/usr/bin/php 1.php