1. 程式人生 > >memcached安裝和php擴展memcache安裝

memcached安裝和php擴展memcache安裝

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

make && make install

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.檢查服務:

[[email protected] 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


[[email protected] vhost]# tail -2 /usr/local/php/etc/php.ini

[memcache]

extension = memcache.so

[[email protected] vhost]# tail -2 /usr/local/php/etc/php.ini

[memcache]

extension = memcache.so


7.測試:

cat test.php

<?php

phpinfo()

?>


本文出自 “10931853” 博客,請務必保留此出處http://wujianwei.blog.51cto.com/10931853/1961541

memcached安裝和php擴展memcache安裝