CentOS 下安裝 Memcache

CentOS 下安裝 Memcache

  • CentOS
  • Memcache
  • php

下載安裝

查看相關軟件包

Yum search memcached 

有了,可以進行安裝了

Yum -y install memcached

Memcache關聯php

yum -y install php-pecl-memcache

驗證安裝結果

memcached -h
php -m | grep memcache

Memcache的基本設置
啓動memcache的服務端:

memcached -d -m 100 -u root -l 222.186.xx.xxx -p 11211 -c 512 -P /tmp/memcached.pid

參數說明

-d 選項是啓動一個守護進程;
-m 是分配給Memcache使用的內存數量,單位是MB,我這裏是100MB;
-u 是運行Memcache的用戶,我這裏是root;
-l 是監聽的服務器IP地址我這裏指定了服務器的IP地址222.186.xx.xxx;
-p 是設置Memcache監聽的端口,我這裏設置了11211,最好是1024以上的端口;
-c 選項是最大運行的併發連接數,默認是1024,我這裏設置了512,按照你服務器的負載量來設定;
-P 是設置保存Memcache的pid文件,我這裏是保存在 /tmp/memcached.pid;

使用

檢查memcached是否啓動

Netstat -an | more
tcp  0  0 222.186.xx.xxx:11211       0.0.0.0:*                   LIST

設置開機啓動

Chkconfig memcached on

啓動和停止

Service memcached start | stop
Or /etc/init.d/memcached start | stop

重啓centos

Shutdown -r now
Or reboot

編寫 php 文件來驗證 memcache 是否可用吧。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章