在Mac上为MAMP编译memcache时,PHP API版本不匹配


PHP API version mismatch compiling memcache for MAMP on Mac

我的原生Apache/PHP设置可以正确使用PHP 5.3.15和memcache。那里一切都很好。但是我也希望能够在本地运行PHP5.2实例。所以我决定最简单的方法就是使用MAMP。

安装MAMP很容易,服务器几秒钟就启动了。我遇到的唯一问题是编译和安装5.2.17的memcache扩展(MAMP附带的版本)。

以下是我安装它的步骤:

  1. 下载了PHP 5.2.17源文件,并将它们放在我的MAMP/bin/php/php5.2.17/include/php文件夹
  2. 已下载memcache-2.2.7并将内容提取到/tmp
  3. $ /Applications/MAMP/bin/php/php5.2.17/bin/phpize为5.2.17设置env
  4. $ MACOSX_DEPLOYMENT_TARGET=10.8 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Applications/MAMP/bin/php/php5.2.17/bin/php-config
  5. $ make
  6. $ cp /tmp/memcache-2.2.7/memcache-2.2.7/modules/memcache.so /Applications/MAMP/bin/php/php5.2.17/lib/php/extensions/no-debug-non-zts-20060613
  7. extension=memcache.so添加到我的php.ini中
  8. 已重新启动服务器

这是phpize:的输出

Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
configure.in:3: warning: prefer named diversions
configure.in:3: warning: prefer named diversions

我在php日志中得到这个错误:

04-Jul-2013 00:32:03] PHP Warning:  PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20090626, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=0
These options need to match in Unknown on line 0

从phpize命令,我本以为扩展是用正确的API版本构建的。但API日志告诉我的情况并非如此。值得注意的是,20090626是我的原生PHP的API版本。所以我认为它仍然是用我的原生版本编译的(虽然不确定)。

有人知道为什么它没有使用正确的API版本编译吗?

好的,所以如果你使用的是PHP 5.2.17,你必须使用memcache-2.2.5才能正确加载。我已经考虑这个问题几天了,决定编译一个旧版本,它成功了!!感谢上帝!