简体   繁体   English

如何使用正确的模块api版本构建mongo.so或PHP

[英]How to build mongo.so or PHP with the correct module api version

Trying to install mongoDB on my MAMP setup. 尝试在我的MAMP设置上安装mongoDB。 I have MAMP 3.05, which comes with PHP 5.5.10. 我有MAMP 3.05,它随PHP 5.5.10一起提供。 Installed mongo using the instructions from the mongo website and it seems to be running properly. 按照mongo 网站上的说明安装了mongo,它似乎运行正常。 Grabbed mongo extension from the mongo github page and followed their instructions for building and adding the extension to php.ini. 从mongo github 页面获取 mongo扩展,并按照他们的说明构建扩展并将其添加到php.ini。

Everything seems ok until I restart MAMP. 在我重新启动MAMP之前,一切似乎都还可以。 In php_error.log, I see this: 在php_error.log中,我看到以下内容:

PHP Warning:  PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20100525
PHP    compiled with module API=20121212
These options need to match
 in Unknown on line 0

It looks like the API number for php is a later version, so it would be nice not to have to rebuild an older version of PHP. 看来php的API编号是更高版本,因此不必重建较旧版本的PHP会很好。 Is there a way to rebuild the mongo extension with the correct module version, or do I have to discard MAMP and build PHP manually? 有没有一种方法可以使用正确的模块版本重建mongo扩展,还是我必须放弃MAMP并手动构建PHP?

Please check with the command which phpize if you use the correct version of the phpize command. 请使用以下命令检查which phpize ,如果你使用正确版本phpize命令。 This should point to a directory similar to the one you installed your PHP5 into. 这应该指向与您将PHP5安装到的目录类似的目录。 Mine is found in /usr/bin/phpize which is the default OS X installation. 我的位于/usr/bin/phpize ,这是默认的OS X安装。

You can further run phpize -v to check the API version it links against. 您可以进一步运行phpize -v来检查其链接的API版本。 In my case (the default OS X PHP installation) it outputs: 就我而言(默认的OS X PHP安装),它输出:

Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

If the outputted API version does not match your required number 20121212 (in my case it is 20100412 which does not match) you are using the wrong phpize to configure the extension. 如果输出的API版本与您所需的编号20121212不匹配(在我的情况下为20100412 ,该编号不匹配),则说明您使用了错误的phpize来配置扩展名。

你必须先做

 sudo cp -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S‌​DKs/MacOSX10.10.sdk/usr/include/php /usr/include/php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM