Home > php教程 > php手册 > PHP5.4.X与Memcache不兼容问题解决方案

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

WBOY
Release: 2016-06-13 10:10:46
Original
1205 people have browsed it

今天把自己的环境安装了最新的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') );

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template