3

I get this error when i try to run following command sudo pecl install mongo

Error:

...php_mongo.c:22:10: fatal error: 'php.h' 
file not found 
  #include <php.h> 
         ^ 
  1 error generated. 
  make: *** [php_mongo.lo] Error 1 
  ERROR: `make' failed 

I am new to MAC, please help me to resolve this and get Mongo Working with PHP.

I have installed MacPorts and autoconf

suresh
  • 2,365
  • 1
  • 26
  • 36
  • 1
    Did you install the xampp "Developer Package", too? See http://www.apachefriends.org/en/xampp-macosx.html#849 – aurora May 23 '12 at 18:20
  • @harald Thanks very much. That was indeed the issue. Can you answer the question, i can mark it as accepted answer. I found many ppl over the web with same issue(google groups and all), but with no answers. This will help others to find answer. – suresh May 23 '12 at 18:53
  • sure ... and i reworded it a little bit. i'm glad i could help :-) – aurora May 24 '12 at 12:40

4 Answers4

12

It seems, that you did not install the xampp "Developer Package", required to build additional php extension. You can download the "Developer Package" from:

http://www.apachefriends.org/en/xampp-macosx.html#849

aurora
  • 9,607
  • 7
  • 36
  • 54
  • 7 Years on: There is no seperate download for Developer Package. Download the full installer and check the "Developer Package" box on the installation Wizard. – Moe Aug 06 '19 at 00:51
3

This has already been answered.

Please follow the processes outlined in this answer - Install PECL on Mac OS X 10.6.

I followed the process outlined here http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/, referenced by the above Stackoverflow link and the process for install pear, followed by pecl and subsequently -

sudo pecl install mongo

works perfectly on OSX Lion.

You may need to modify the extensions in /etc/php.ini, however, this is explained in the output after you install the php mongo driver.

Community
  • 1
  • 1
Mark Hillick
  • 6,853
  • 1
  • 19
  • 23
  • Yes this method will work. But i used xampp in which case the php headers were missing from the xampp folders. – suresh May 23 '12 at 19:50
  • 1
    @MarkHillick: I'm still getting `file not found. #include ` when using `sudo pecl install mongo`. Any ideas? – Sherzod Feb 24 '13 at 23:22
  • @shershams http://stackoverflow.com/questions/3772582/mongodb-and-mamp/15531409#15531409 – AbdullahDiaa Nov 07 '13 at 17:37
1

It took me the whole day to find this answer, I had tried everything, but this worked finally:

    sudo C_INCLUDE_PATH=/usr/local/opt/openssl/include /Applications/XAMPP/xamppfiles/bin/pecl install mongodb
Ethan SK
  • 736
  • 8
  • 12
  • This worked for me except at the very end it fails to copy the file. ERROR: failed to write /usr/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so (copy(/usr/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so): failed to open stream: Operation not permitted) – Matt Apr 18 '18 at 15:52
0

I found this article very helpful. Saved a lot of time after I wasted a lot of time to check other links. I did for MAMP and think will work for XAMPP too.

The thing is MAMP does not ship with all PHP sources to compile pecl mongo file and create mongo.so. All what you need is download php for respective version you are using. I was using php version 5.6.10. I checked php.net site that was having 5.6.13 version. I downloaded sources for this version from PhP.net. Executed "sudo pecl install mongo" again and it worked.

Himanshu Pathak
  • 193
  • 1
  • 10