如何使用正确的模块api版本构建mongo

如何使用正确的模块api版本构建mongo

本文介绍了如何使用正确的模块api版本构建mongo.so或PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在我的MAMP设置上安装mongoDB.我有MAMP 3.05,它随PHP 5.5.10一起提供.按照mongo 网站中的说明安装了mongo它似乎运行正常.从mongo github 页面中获取了mongo扩展,并按照他们的指示来构建扩展并将其添加到php.ini.

Trying to install mongoDB on my MAMP setup. I have MAMP 3.05, which comes with PHP 5.5.10. Installed mongo using the instructions from the mongo website and it seems to be running properly. Grabbed mongo extension from the mongo github page and followed their instructions for building and adding the extension to php.ini.

在重新启动MAMP之前,一切似乎都还不错.在php_error.log中,我看到了:

Everything seems ok until I restart MAMP. In php_error.log, I see this:

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

看来php的API号是一个更高的版本,因此不必重建一个较旧的PHP版本就很好了.有没有办法用正确的模块版本重建mongo扩展,还是我必须放弃MAMP并手动构建PHP?

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. 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?

推荐答案

请使用命令which phpize检查是否使用了正确版本的phpize命令.这应该指向与您将PHP5安装到的目录相似的目录.我的是在/usr/bin/phpize中找到的,这是默认的OS X安装.

Please check with the command which phpize if you use the correct version of the phpize command. This should point to a directory similar to the one you installed your PHP5 into. Mine is found in /usr/bin/phpize which is the default OS X installation.

您可以进一步运行phpize -v来检查其链接的API版本.就我而言(默认的OS X PHP安装),它输出:

You can further run phpize -v to check the API version it links against. In my case (the default OS X PHP installation) it outputs:

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

如果输出的API版本与您所需的编号20121212不匹配(在我的情况下为20100412,该数字不匹配),则说明您使用了错误的phpize来配置扩展名.

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版本构建mongo.so或PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 18:55