问题
I spent 2 days trying to install mongo php driver on a Mac 10.8 with MAMP (2.2), but it's almost impossible... I've tried: Installing Mongo Driver on MAMP and this Mongo PHP Driver 1.2.10 with MAMP
I have the 5.4.19 php version selected on MAMP.
I have installed the mongo driver doing:
sudo pecl install mongo
I have no errors, but once I restart MAMP I got this error on the loading process:
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20090626
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0
The output of phpize is:
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
The output of php -v is:
PHP 5.5.3 (cli) (built: Sep 18 2013 14:31:13) ...
So the version doesn't match with MAMP. I have tried to select the same version on MAMP, but I got the same problem...
Any hints?
Thank you very much!
回答1:
The phpize
in your path is building extensions for PHP 5.3 (API version 20090626), but you need to match the API version of PHP in your MAMP config (which should be API version 20100412 for PHP 5.4). It looks like you have another version of php
in your path, which is PHP 5.5.
To build everything with the expected version of PHP, try putting that version of PHP first in your path, eg:
export PATH=/Applications/MAMP/bin/php/php5.4.19/bin:$PATH
Then run phpize
to make sure it finds the correct API version.
The API version reported by phpize -v
should match that reported by php -i | grep "PHP API"
.
Assuming all matches, you should then be able to build following the instructions you've linked.
来源:https://stackoverflow.com/questions/21558690/mongo-php-driver-with-mamp