简体   繁体   中英

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

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.

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

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?

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.

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

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.

你必须先做

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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