天天看點

memcached安裝和php擴充memcache安裝

1.準備安裝包:

libevent-2.1.8-stable.tar.gz

memcached-1.5.0.tar.gz

memcache-2.2.7.tgz 

2.安裝libevent

tar xf /opt/libevent-2.1.8-stable.tar.gz 

cd libevent-2.1.8-stable

mkdir /usr/local/libevent 

./configure --prefix=/usr/local/libevent

make && make install

echo $?

3.安裝memcached

tar xf memcached-1.5.0.tar.gz -C /opt/

mkdir /usr/local/memcached

cd /opt/memcached-1.5.0

./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent

id www

memcached參數

-d  選項是啟動一個守護程序,

-m  是配置設定給Memcache使用的記憶體數量,機關是MB

-u  是運作Memcache的使用者,如果目前為 root 的話,需要使用此參數指定使用者。

-l  是監聽的伺服器IP位址

-p  是設定Memcache監聽的端口, 最好是1024以上的端口

-c  是最大運作的并發連接配接數,預設是1024

-P 是設定儲存Memcache的pid檔案,我這裡是儲存在 /tmp/memcached.pid

4.普通使用者啟動memcached:

/usr/local/memcached/bin/memcached -d -u www -m 4096 -l 127.0.0.1 -c 10000 -p 11313 -P /tmp/11313.pid

5.檢查服務:

[root@localhost memcached-1.5.0]# netstat -lp | grep memcached

tcp        0      0 localhost:11313             *:*                         LISTEN      19688/memcached     

udp        0      0 localhost:11313             *:*                                     19688/memcached 

6.安裝php擴充memcache

tar xf /opt/memcache-2.2.7.tgz -C /opt/

cd /opt/memcache-2.2.7

find / -name "php-config"

/usr/local/php/bin/phpize

./configure --enable-memcache=/usr/local/memcached --with-php-config=/usr/local/php/bin/php-config 

make &&make install

[root@localhost vhost]# tail -2 /usr/local/php/etc/php.ini 

[memcache]

extension = memcache.so

7.測試:

cat test.php

<?php

phpinfo()

?>

 本文轉自 wjw555 51CTO部落格,原文連結:http://blog.51cto.com/wujianwei/1961541