centos下安装memcache和memcached for php

安装memcache
1.cd /usr/local/src
2.下载memcache版本wget http://pecl.php.net/get/memcache-3.0.6.tgz
3.解压tar xzvf memcache-3.0.6.tgz
4.进入cd memcache-3.0.6
5.安装输入命令(一次一条)
# /usr/local/php/bin/phpize
# ./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir
# make && make install
6.修改php.ini文件
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
extension=memcache.so
7.查看下模块是否载入php -m
8.重启apache service httpd restart

安装memcached
1.# yum install libevent-devel
# cd /usr/local/src
# wget http://pecl.php.net/get/memcached-2.1.0.tgz
# tar vxf memcached-2.1.0.tgz
# cd memcached-2.1.0
# ./configure –prefix=/usr/local/memcached
# make && make install

2.安装完后启动memcached并分配32m内存(32为使用内存数,可按自身情况修改)
/usr/local/memcached/bin/memcached -d -m 32 -l 127.0.0.1 -p 11211 -u root

3.将memcached加入启动项

# vi /etc/rc.d/rc.local
按键盘上的 i 开始编辑
在最后加入

/usr/local/memcached/bin/memcached -d -m 32 -l 127.0.0.1 -p 11211 -u root
按Esc键,再输入
:wq