memcache 安装

来源:互联网 发布:2345电脑软件软件大全 编辑:程序博客网 时间:2024/04/27 19:08

1. 安装 libevent 
tar zxvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure –prefix=/usr
make
make install

2. 安装memcached,同时需要安装中指定libevent的安装位置
tar zxvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure –with-libevent=/usr
make && make install

3. 测试是否成功安装memcached
ls -al /usr/local/bin/mem*
-rwxr-xr-x 1 root root 201869 12-14 21:44 /usr/local/bin/memcached

4. 安装Memcache的PHP扩展
(1)
tar vxzf memcache-2.2.5.tgz
cd memcache-2.2.5
/usr/local/php5/bin/phpize(注意:如果这个地方报Cannot find autoconf. Please check your autoconf installation and the $PHP,则执行 yum install automake)
./configure –enable-memcache –with-php-config=/usr/local/php5/bin/php-config –with-zlib-dir
make
make install

(2)添加一行来载入memcache扩展:extension=memcache.so

(3)启动memcache 服务端
memcached -d -m 10 -u root -l 127.0.0.1 -p 11211 -c 256 -P /tmp/memcached.pid

结束进程: kill `cat /tmp/memcached.pid`

检查进程:netstat -ant
另外装好之后需要reboot 一下。

另外memcached自启动 在 /etc/rc.d/rc.local
加上 /usr/local/memcache/bin/memcached -d -m 10 -u root -l 127.0.0.1 -p 11211 -c 256 -P /tmp/memcached.pid
即可