Nojan
Nojan

Reputation: 913

Unable to initialize mongoDB module on MAMP

I've installed MongoDB using homebrew and also installed the php mongo driver and included it in the current php version of my MAMP package. But when I start MAMP this error is in my php error log:

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

I tried to compile the driver again with the phpize which is inside the mamp folder but got the same results. I'm very new to mac and *nix environment in general, Is there something that I'm missing?

The PHP version installed by homebrew is 5.5.17 and PHP version in my MAMP Package is 5.5.14

Upvotes: 0

Views: 797

Answers (1)

jmikola
jmikola

Reputation: 6922

If you're compiling the PHP driver, you must do so against the same PHP version that you intend to run it with. Based on the error you've shared, the driver was clearly compiled against a different PHP runtime.

Luke Peters has a blog post discussing how to compile the module for MAMP, and it entails setting your PATH environment variable to MAMP's bin/ directory before using PECL to build the module. This will ensure that the appropriate phpize binary gets used. To paraphrase his write-up for your environment (5.5.14):

$ export PATH=/Applications/MAMP/bin/php/php5.5.14/bin:$PATH`
$ cd /Applications/MAMP/bin/php/php5.5.14/bin
$ sudo pecl install mongo

Upvotes: 1

Related Questions