Memcached的官網(wǎng)http://memcached.org/](http://memcached.org/。
一進(jìn)去就可以看見(jiàn) ”What is Memcached?“。英文的重要性。
Memcached 是一個(gè)高性能的分布式內(nèi)存對(duì)象緩存系統(tǒng),用于動(dòng)態(tài)Web應(yīng)用以減輕數(shù)據(jù)庫(kù)負(fù)載。
http://memcached.org/downloads 可以看見(jiàn)教你怎么安裝。
Installation:Debian/Ubuntu: apt-get install libevent-dev Redhat/Centos: yum install libevent-devel
我的是centos6.5,所以就是,看下面。
//依賴(lài):
yum install libevent-devel -y
wget http://memcached.org/files/memcached-1.4.31.tar.gz
tar -zxvf memcached-1.4.31.tar.gz
cd memcached-1.4.31
./configure --prefix=/usr/local/memcached
make && make install
//簡(jiǎn)單啟動(dòng)
./memcached -p 11211 -d -u root -m 1024 -c 1024 -l 127.0.0.1
-p 端口
-d 守護(hù)進(jìn)程方式
-u root代表當(dāng)前用戶(hù)。最好不用root
-m 代表分配內(nèi)存
-c 代表 最大連接上
-l 綁定地址。如果沒(méi)有,誰(shuí)都可以連
//連接和退出
telnet 127.0.0.1 11211
quit
//基本命令
set、add、replace、get、delete
//勾結(jié)php7有要麻煩點(diǎn)。
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz //centos
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure
make && make install
ldconfig //最好執(zhí)行一下 清除緩存
yum -y install git //安裝git,沒(méi)有g(shù)it,就安裝git
git clone https://github.com/php-memcached-dev/php-memcached.git 來(lái)下載
cd php-memcached //跑到里面去
git checkout php7 //進(jìn)入php7分支
/usr/local/php/bin/phpize //就是phpize是用來(lái)擴(kuò)展php擴(kuò)展模塊的,通過(guò)phpize可以建立php的外掛模塊。
./configure --with-php-config=/usr/local/php/bin/php-config --disable-memcached-sasl
make && make install
//不出現(xiàn)什么錯(cuò)誤 出現(xiàn)這條/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012
//一般是完成了。
在php.ini后面加上 extension="memcached.so"
echo 'extension="memcached.so"' >> /usr/local/php/lib/php.ini
//重啟httpd會(huì),phpinfo() 會(huì)出現(xiàn) memcached
或者/usr/local/php/bin/php -m //可以看見(jiàn)memcached