girl 2012-4-13 18:55
在 CentOS 下安裝 memcached 服務
可以使用21andy 的 yum 來安裝...<div><br></div><div>先新建一個 repo</div><div>[quote]</div><div># vi /etc/yum.repos.d/centos.21andy.com.repo</div><div>[/quote]</div><div><br></div><div>放入如下内容</div><div>[quote]</div><div>[21Andy.com]<br>name=21Andy.com Packages for Enterprise Linux 5 - $basearch<br>baseurl=http://www.21andy.com/centos/5/$basearch/<br>enabled=1<br>gpgcheck=0<br>protect=1</div><div>[/quote]</div><div><br></div><div>啟用 EPEL repo<br>i386</div><div>[quote]</div><div>rpm -ihv http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm</div><div>[/quote] </div><div><br></div><div>x86_64</div><div>[quote]</div><div>rpm -ihv http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm</div><div>[/quote]</div><div><br></div><div>接著導入key</div><div>[quote]</div><div>rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL</div><div>[/quote]</div><div><br></div><div>好了,安裝</div><div>[quote]</div><div># yum install memcached</div><div>[/quote]</div><div><br></div><div>安裝成功後...設定檔在 /etc/sysconfig/memcached</div><div>[quote]</div><div><div>PORT="11211"</div><div>USER="memcached"</div><div>MAXCONN="1024"</div><div>CACHESIZE="64"</div><div>OPTIONS=""</div></div><div>[/quote]</div><div><br></div><div>預設使用的Port 是11211</div><div>你可以調整memcache 配置的大小... CACHESIZE 預設是64M</div><div><br></div><div>啟用服務</div><div>[quote]</div><div>#service memcached start</div><div>[/quote]</div><div><br></div><div>當memcached服務啟用之後... PHP 也要安裝 php-pecl-memcache 的Module...</div><div>[quote]</div><div># yum install php-pecl-memcache</div><div>[/quote]</div><div><br></div><div>之後Apache重啟...確認一下Module是否已安裝</div><div>[quote]</div><div><div># php -m | grep memcache</div><div>memcache</div></div><div>[/quote]</div><div><br></div><div>有跑出 memcache 就代表PHP Module 已經安裝成功啦~~</div><div><br></div><div>在系統下...可以執行指令看本機 memcache 的使用狀態</div><div>[quote]</div><div># memcached-tool localhost stats</div><div>[/quote]</div><div><br></div><div>另外也可以下載PHP程式...使用圖形化界面觀看...而且還可以直接在web上清cache...很方便...如下圖:</div><div><img src="http://livebookmark.net/journal/wp-content/uploads/2008/05/memcache.png" border="0" width="800"><br></div><div><br></div><div><font size="4" color="#0000ff">程式下載:</font></div><div><a href="http://livebookmark.net/memcachephp/memcachephp.zip" target="_blank"><font color="#696969">Memcache php程式</font></a></div>