memcache和memcached安装
首先要明確? memcache不是memcached
?
第一步安裝libevent
#wget? https://github.com/downloads/libevent/libevent/libevent-2.0.15-stable.tar.gz
#tar libevent-2.0.15-stable.tar.gz
#tar xzvf libevent-2.0.15-stable.tar.gz
#cd libevent-2.0.15-stable
#./configure --help
#whereis libevent
#./configure --prefix=/usr
#ls -al /usr/lib|grep libevent
#make
#make install
#ls -al /usr/lib|grep libevent
#ldconfig -v
#ldconfig
--------------------------------------------------------------------------------------------?
?
第二步安裝memcached
# wget http://memcached.googlecode.com/files/memcached-1.4.9.tar.gz
#tar xzvf memcached-1.4.9.tar.gz
#cd memcached-1.4.9
#./configure --help
#./configure --prefix=/usr/local/memcached --with-libevent=/usr
#make
#make install
#ls /usr/local/memcached/bin/memcached -lh
#netstat –ntlpu
#/usr/local/memcached/bin/memcached -d -m 100 -uroot -l 0.0.0.0 -p 11211 -c 512 -P /usr/local/memcached/memcached.pid
#netstat -ntlpu
-------------------------------------------------------------------------
memcached進程的查看與結束
#ps aux|grep mem
#cat /usr/local/memcached/memcached.pid
#ps aux 也可以查進程
殺死memcached進程
#kill?? 進程id
---------------------------------------------------------------------------------
?
第三步 安裝php的memcached擴展memcache
#wget http://pecl.php.net/get/memcache-2.2.6.tgz
#tar vxzf memcache-2.2.6.tgz
#cd memcache-2.2.6
#/usr/local/php/bin/phpize
#./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir
或者
#./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir=/usr
#make
#make install
?
/usr/local/php/lib/php.ini
php.ini添加
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
;extension=memcache.so
如果程序沒有dl("memcache.so");是要這里加的。
?
-----------------------------------------------------------------------
測試
Memcache環境測試:
運行下面的php文件,如果有輸出This is a test!,就表示環境搭建成功。開始領略Memcache的魅力把!
< ?php
$mem = new Memcache;
$mem->connect(”127.0.0.1″, 11211);
$mem->set(’key’, ‘This is a test!’, 0, 60);
$val = $mem->get(’key’);
echo $val;
?>
?--------------------------------------------------
連接Memcached
#telnet? ip?? 端口
狀態stats回車
退出quit回車
總結
以上是生活随笔為你收集整理的memcache和memcached安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 侏罗纪世界电影中的迅猛龙的力气有多大?
- 下一篇: ldconfig命令详解,linux动态