一、先安裝macport apache
sudo port selfupdate #更新當前Marport (若是port 不能夠時能夠考慮此操做)服務器
sudo prot -d selfupdate #替換更新Marport(若是port 不能夠時能夠考慮此操做)併發
sudo port help #查看幫助memcached
sudo prot list #查看已經按照大軟件列表spa
二、安裝memcahed rest
port install memcahed or install memcached 用Port安裝memcached進程
memcached -help 查看幫助內存
memcached -d -P /tmp/memcached.pid -u root #啓動服務器class
telnet 127.0.0.1 11211服務器端
kill `cat /tmp/memcached.pid`
memcached的基本設置:
1.啓動Memcache的服務器端:
# /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 -p 12000 -c 256 -P /tmp/memcached.pid
-d選項是啓動一個守護進程,
-m是分配給Memcache使用的內存數量,單位是MB,我這裏是10MB,
-u是運行Memcache的用戶,我這裏是root,
-l是監聽的服務器IP地址,若是有多個地址的話,我這裏指定了服務器的IP地址192.168.0.200,
-p是設置Memcache監聽的端口,我這裏設置了12000,最好是1024以上的端口,
-c選項是最大運行的併發鏈接數,默認是1024,我這裏設置了256,按照你服務器的負載量來設定,
-P是設置保存Memcache的pid文件,我這裏是保存在 /tmp/memcached.pid,
2.若是要結束Memcache進程,執行:
# kill `cat /tmp/memcached.pid`
也能夠啓動多個守護進程,不過端口不能重複。
3.重啓apache,service httpd restart