Thursday, April 25, 2013

Installing Mongo driver on MAMP/MAMP PRO

I recently acquired a Mac development station and have been loving it so far. The only hiccup I have hit so far is installing the Mongo driver in MAMP. My progress yesterday can be found here:

http://www.reddit.com/r/mac/comments/1d1iuf/newtomac_web_developer_has_a_few_questions/c9m53j7

As MAMP is running PHP 5.4.10 I tried unzipping the official 5.4.10 release so the paths matched the not found paths in my reddit post from yesterday. While that got me a bit further I hit another stumbling block.


Jareds-MacBook-Air:bin root# ./pecl install mongo
downloading mongo-1.3.7.tgz ...
Starting to download mongo-1.3.7.tgz (126,064 bytes)
............................done: 126,064 bytes
49 source files, building
WARNING: php_bin /Applications/MAMP/bin/php/php5.4.10/bin/php appears to have a suffix /php5.4.10/bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed


Looks like I need autoconf.


So to get autoconf it looks like people are using the brew package manager. To get brew to work properly you need to get the xcode command line tools. How do you get that? You get xcode. Yeesh.


Jareds-MacBook-Air:bin jared$ brew doctor
Your system is ready to brew.
Jareds-MacBook-Air:bin jared$ brew install autoconf
==> Downloading http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/autoconf/2.69
==> make install
🍺  /usr/local/Cellar/autoconf/2.69: 69 files, 2.0M, built in 8 seconds

Hopefully the mongo driver will build now. Hold onto your butts.....


Well, it got a whole lot futher this time.... then died here:



In file included from /Applications/MAMP/bin/php/php5.4.10/include/php/main/php.h:34:
/Applications/MAMP/bin/php/php5.4.10/include/php/Zend/zend.h:51:11: fatal error: 'zend_config.h' file not found
# include <zend_config.h>
          ^
1 error generated.
make: *** [php_mongo.lo] Error 1
ERROR: `make' failed

Hopefully I'm getting close. After more digging it looks like I first need to configure the source code I downloaded earlier


Jareds-MacBook-Air:php jared$ pwd
/Applications/MAMP/bin/php/php5.4.10/include/php


Jareds-MacBook-Air:php jared$ ./configure

Alright.. Seriously this time...



Jareds-MacBook-Air:bin jared$ sudo ./pecl install mongo
~~~ BLAH BLAH BLAH COMPILING ~~~
You should add "extension=mongo.so" to php.ini



Success! Now to find where it put this thing... Looks like


/Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/mongo.so

Now to add it to MAMP's php.ini...

extension=/Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/mongo.so

Alright.. Saved. Restarting MAMP... Time to check phpinfo()... looks good! If someone would like me to clean this up into something more readable drop me a comment and I will create a new post with just the instructions. 

2 comments:

Santos said...

I followed 2 tutorials to get done the job!!
First I went to this
http://lukepeters.me/blog/post/setting-up-mongodb-with-php-and-mamp

But then I got an Zend error and i came here via google!!

Unknown said...

Thanks man, this has been driving me around the bend