一、所需资源
1、Memcache : http://pecl.php.net/package/memcache
二、从源码安装
注:
php的安装目录是: /usr/local/php
zlib的安装目录是: /usr/local/zlib
1、安装memcache
#下载解压wget-c http://pecl.php.net/get/memcache-3.0.6.tgz
tar xzvf memcache-3.0.6.tgz
cd memcache-3.0.6
#配置/usr/local/php/bin/phpize
./configure--enable-memcache--with-php-config=/usr/local/php/bin/php-config--prefix=/usr/local/memcache/--with-zlib-dir=/usr/local/zlib
make&&make
install
如遇到错误: Cannot find autoheader. Please check your autoconf
installation and the
$PHP_AUTOHEADER environment variable. Then, rerun this script.
请看下面(三、1)
如遇到错误:error: too few arguments to function
‘zend_list_insert’请看下面(三、2)
安装完后会有类似这样的提示:
Installing shared extensions:
/usr/local/php/lib/php/extensions/no-debug-non-zts-20060922/
把这个记住,在修改php.ini时用到
#最后修改php.ini文件,在zend之前加入如下代码。[memcache]
extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060922/"
extension=memcache.so
重启服务,安装完毕
三、遇到错误
1、: Cannot find autoheader. Please check your autoconf installation
and the
$PHP_AUTOHEADER environment variable. Then, rerun this script.
解决:
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.gz
tar-zxvf autoconf-2.65.tar.gz
cd autoconf-2.65
./configure--prefix=/usr/local/autoconf
make&&make
install
export PHP_AUTOCONF=/usr/local/autoconf/bin/autoconf
export PHP_AUTOHEADER=/usr/local/autoconf/bin/autoheader
2、遇到 error: too few arguments to function ‘zend_list_insert’
这个是什么原因呢,回去看看configure的时候有什么警告没。这里果然有个警告:
configure: WARNING: You will need re2c 0.13.4 or later if you want
to regenerate PHP parsers.
解决:
打开memcache.c文件,
将所有的:zend_list_insert(pool, le_memcache_pool);
改为:zend_list_insert(pool, le_memcache_pool TSRMLS_CC);
保存,退出继续编译,成功搞定!