首页 > php安装 > PHP5.4.X与Memcache不兼容问题解决方案

PHP5.4.X与Memcache不兼容问题解决方案

今天把自己的环境安装了最新的PHP5.4.8,结果在与Memcache时出现了不兼容问题,结过反复调度总结了不兼容的原因与解决办法.

emcache(sudo pecl install memcache)PHP扩展,编译后memcache.so在/usr/lib/php5/20090626/中,在PHP.ini添加好extension,重启phpfpm,不是重启nginx,出现下面的错误信息:

Gracefully shutting down php-fpm . done 

Starting php-fpm [25-Oct-2012 12:04:02] NOTICE:  

PHP message: PHP Warning:  PHP Startup: memcache: Unable to initialize module

Module compiled with module API=20090626 

PHP    compiled with module API=20100525 

These options need to match 

编译PHP使用的PHP核心版本是20100525,而Pecl里面的Memcache是使用20090626版本编译的,版本不一致导致PHP无法启用memcache.so库,解决方法是卸载掉Pecl方式安装的Memcache,去pecl.php.net/package/memcache下载源码包自己编译,代码如下:

##卸载memcache 

sudo pecl uninstall memcache 
 
phpize 
./configure --enable-memcache --with-php-conf=/usr/local/php/bin/php-config 
make 
make install

启动memcached服务:memcached -d -m 256 -p 11211,测试脚本:OK,代码如下:

$mem = new Memcache; 
$mem->connect('127.0.0.1',11211); 
$mem->set('feiyan','blog'); 
var_dump( $mem->get('feiyan') );


本文地址:http://www.phprm.com/install/fs4795.html

转载随意,但请附上文章地址:-)

标签:php5.4.x memcache不兼容

发表留言