Debian5 安装PHP5的memcached模块

   debian5已经发布好几年了,默认自带的PHP是5.2.6,也带有php5-memcache模块,但是后来出现了更好用的php5-memcached模块,而php5-memcached在debian6中,老机器机器都是debian5且跑有重要服务,怎样安装php5-memcached模块呢?

    有个工具是pecl,pecl需要php5-dev php-pear这两个包支持,可以用它安装memcached:pecl install memcached,但是它会一直提示找不到libmemcached-1.0/memcached.h头文件,这是个bug,所以我们换下面的方法:

1 更改debian5的源为debian6

vi /etc/apt/sources.list
deb http://mirrors.163.com/debian/ squeeze main non-free contrib
deb http://mirrors.163.com/debian/ squeeze-proposed-updates main non-free contrib
deb http://mirrors.163.com/debian-security/ squeeze/updates main non-free contrib
2 安装libmemcached5 libmemcached-dev

apt-get update
apt-get install libmemcached5 libmemcached-dev
    为什么不直接安装php5-memcached呢,因为这样会更新整个php5的环境,所以我们只安装memcached的lib库

3 下载memcached-2.1.0.tgz源码包

wget 'http://pecl.php.net/get/memcached-2.1.0.tgz'
4 安装memcached模块

tar zxvf memcached-2.1.0.tgz
cd memcached-2.1.0/
phpize
./configure
make
#make时发现也会提示找不到libmemcached-1.0/memcached.h文件
5  查找memcached.h的具体路径

dpkg -L libmemcached-dev  | grep memcached.h
6  修改 memcached-2.1.0.tgz中的php_libmemcached_compat.h

vi php_libmemcached_compat.h
/*#include <libmemcached-1.0/memcached.h> */
#include </usr/include/libmemcached/memcached.h>
7  然后重新安装即可

8  把编译好的memcached.so加入配置文件中

cd /etc/php5/conf.d
touch memcached.ini
extension=memcached.so
9  重启apache即可生效



你可能感兴趣的:(Debian5)