3

I'm trying to get the latest Mongo Driver to work with MAMP 1.9.6 on OS X 10.5.8.

I built it successfully from source since it seems that there are no pre-compiled releases, included it into the right directory and restarted the apache.

But PHP doesn't recognize the extension. I used the 1.0.11 driver previously which worked fine, but I need the new version, because Doctrines ODM requires it.

When I replace the 1.2.10 mongo.so with the 1.0.11 and restart apache mongo is available. I don't get what could be wrong.

Anyone had this behaviour or any guesses to get this to work?

Update: The PHP error log shows the following:

[01-Jun-2012 22:02:37] PHP Warning:  PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20060613
PHP    compiled with module API=20090626
These options need to match
 in Unknown on line 0

I'm not quite sure what it means?

2. Update: I was finally able to sync the API version of phpize.

But now I'm not able to build the driver anymore.

I do the following:

phpize
./configure
make
sudo make install

But at the make command I'm getting tons of syntax errors. Seems that it can't find several header files.

The very first one is the zend_config.h and really I just have those other two files:

zend_config.nw.h
zend_config.w32.h

I downloaded the MAMP components to get this files. Why am I missing this one? And there are a lot of others.

I'm using PHP 5.3.5 Is there a way to get those header files from a different source?

Johannes Klauß
  • 10,676
  • 16
  • 68
  • 122
  • Look for PHP startup errors (enable logging here). I'd say for some reason PHP is unable to load the binary extension. Maybe some compilation problem. – hakre Jun 01 '12 at 19:57
  • Okay, as it tells, the API version mistmatches. When you compile the module, specify that you need to use API 20090626. You have used API 20060613 which is far outdated. – hakre Jun 01 '12 at 20:14
  • AFAIK that's something you specify with the build script. See as well [How to set the PHP Api Version for phpize](http://serverfault.com/questions/44668/how-to-set-the-php-api-version-for-phpize) which does not fully answer the question (at least not generally) but should give you some pointers. – hakre Jun 01 '12 at 20:51
  • I was able to sync that, but as you can see above I'm not able to build it anymore. – Johannes Klauß Jun 01 '12 at 22:21
  • have you donwloaded whoe PHP source-code? If not fetch it from git, see as well http://hakre.wordpress.com/2012/05/20/php-on-heroku-again/ , scroll down it has a section about how to compile a PHP module "from sources" while downloading whole PHP sourcecode from github. – hakre Jun 01 '12 at 22:23

3 Answers3

3

I followed the instructions at Develop MongoDB web apps with MAMP under Mac OS X to successfully build mongo.so for MAMP with php 5.3 on OS X 10.7.3.

Stennie
  • 63,885
  • 14
  • 149
  • 175
2

I'm adding this for historical purposes -- I guarantee that if you're having the same set of problems, you'll want to do this.

Personally, I had a really difficult time getting MAMP's php version to play nicely with the extension builds that I was trying to make.

I discovered that the problem was that MAMP really hadn't been set up to add extensions in general, and during the compilation of the mongo php drivers, it wasn't installing it in the right place -- so I followed the following tutorial on preparing MAMP for additional pecl and pear extensions.

After following those steps to prepare MAMP for adding extensions, you can easily install any extension.

At the part where it starts talking about adding an extension, use sudo pecl install mongo and restart apache from your MAMP interface.

Kristian
  • 21,204
  • 19
  • 101
  • 176
0

I ran into the same problem when upgrading from PHP 5.3 to 5.4 and was able to solve it by following these steps:

  1. Make sure to upgrade php5-cli as well as just php5 and php5-common

  2. Uninstall the mongo drive

    sudo pecl uninstall mongo
    
  3. Re-install the mongo driver

    sudo pecl install mongo
    
user1055604
  • 1,624
  • 11
  • 28
Kerkness
  • 329
  • 4
  • 9
  • 1
    Welcome to SO! Just a single comment about your answer. For the commands (sudo pecl...), it might be nice to format those as "code." This is easily done by editing your answer and putting either ` characters around the code, or using the formatting tools at the top of the editing window. Thanks! – Greg Dec 27 '12 at 20:00
  • check out this answer for php 5.4.10 with MAMP 2.1.2 http://stackoverflow.com/questions/3772582/mongodb-and-mamp/15531409#15531409 – AbdullahDiaa Mar 20 '13 at 18:09