简体   繁体   English

在Max OS Lion上使用XAMPP安装MongoDb PHP驱动程序时出错

[英]Error installing MongoDb PHP driver with XAMPP on Max OS Lion

I get this error when i try to run following command sudo pecl install mongo 当我尝试运行以下命令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. 我是MAC的新手,请帮我解决这个问题并让Mongo使用PHP。

I have installed MacPorts and autoconf 我已经安装了MacPorts和autoconf

It seems, that you did not install the xampp "Developer Package", required to build additional php extension. 看来,你没有安装xampp“Developer Package”,需要构建额外的php扩展。 You can download the "Developer Package" from: 您可以从以下位置下载“开发者包”:

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

This has already been answered. 这已经得到了解答。

Please follow the processes outlined in this answer - Install PECL on Mac OS X 10.6 . 请按照本答案中列出的流程 - 在Mac OS X 10.6上安装PECL

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 - 我按照这里概述的过程http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/ ,由上面的Stackoverflow链接和安装pear的过程引用,然后是pecl,随后 -

sudo pecl install mongo sudo pecl install mongo

works perfectly on OSX Lion. 在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. 您可能需要修改/etc/php.ini中的扩展名,但是,在安装php mongo驱动程序后,在输出中对此进行了解释。

我花了一整天的时间来找到这个答案,我已经尝试了所有的东西,但最终还是有效:

    sudo C_INCLUDE_PATH=/usr/local/opt/openssl/include /Applications/XAMPP/xamppfiles/bin/pecl install mongodb

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. 我为MAMP做了,并认为也适用于XAMPP。

The thing is MAMP does not ship with all PHP sources to compile pecl mongo file and create mongo.so. 事情是MAMP没有附带所有PHP源代码来编译pecl mongo文件并创建mongo.so。 All what you need is download php for respective version you are using. 所有你需要的是下载你正在使用的相应版本的PHP。 I was using php version 5.6.10 . 我使用的是php 5.6.10版。 I checked php.net site that was having 5.6.13 version. 我检查了拥有5.6.13版本的php.net网站。 I downloaded sources for this version from PhP.net . 我从PhP.net下载了此版本的源代码 Executed " sudo pecl install mongo " again and it worked. 再次执行“ sudo pecl install mongo ”并且工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM