无法在mac os 10.9上安装mongodb php驱动程序。

时间:2021-05-14 10:40:59

After googling for about an hour can't find any solution that works for me. I'm on OS X 10.9 Mavericks.

在谷歌搜索了一个小时后,我找不到任何对我有用的解决方案。我是在OS X 10.9 Mavericks。

Here is what the terminal says:

这是终端说的:

$ sudo pecl install mongo

downloading mongo-1.4.4.tgz ...
Starting to download mongo-1.4.4.tgz (141,242 bytes)
..............................done: 141,242 bytes
84 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
building in /private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4
running: /private/tmp/pear/install/mongo/configure
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i386-apple-darwin13.0.0
checking host system type... i386-apple-darwin13.0.0
checking target system type... i386-apple-darwin13.0.0
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20100525
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable Mongo extension... yes, shared
checking whether byte ordering is bigendian... no
checking whether to compile for recent osx architectures... yes
checking whether to include code coverage symbols... no
checking Build with PHP streams support... yes
checking for ld used by cc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking if cc supports -fno-rtti -fno-exceptions... yes
checking for cc option to produce PIC... -fno-common
checking if cc PIC flag -fno-common works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin13.0.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/libtool --mode=compile cc -I./util -I. -I/private/tmp/pear/install/mongo -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/include -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/main -I/private/tmp/pear/install/mongo -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/util -I/private/tmp/pear/install/mongo/util -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/exceptions -I/private/tmp/pear/install/mongo/exceptions -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/gridfs -I/private/tmp/pear/install/mongo/gridfs -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/types -I/private/tmp/pear/install/mongo/types -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/mcon -I/private/tmp/pear/install/mongo/mcon  -
DHAVE_CONFIG_H  -g -O2 -arch i386 -arch x86_64 -mmacosx-version-min=10.5   -c /private/tmp/pear/install/mongo/php_mongo.c -o php_mongo.lo
mkdir .libs
 cc -I./util -I. -I/private/tmp/pear/install/mongo -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/include -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/main -I/private/tmp/pear/install/mongo -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/util -I/private/tmp/pear/install/mongo/util -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/exceptions -I/private/tmp/pear/install/mongo/exceptions -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/gridfs -I/private/tmp/pear/install/mongo/gridfs -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/types -I/private/tmp/pear/install/mongo/types -I/private/tmp/pear/install/pear-build-rootDzh2iw/mongo-1.4.4/mcon -I/private/tmp/pear/install/mongo/mcon -DHAVE_CONFIG_H -g -O2 -arch i386 -arch x86_64 -mmacosx-version-min=10.5 -c /private/tmp/pea
r/install/mongo/php_mongo.c  -fno-common -DPIC -o .libs/php_mongo.o
/private/tmp/pear/install/mongo/php_mongo.c:16:10: fatal error: 'php.h' file not found
#include <php.h>
         ^
1 error generated.
make: *** [php_mongo.lo] Error 1
ERROR: `make' failed

Maybe someone has already encountered this problem and knows a solution?

也许有人已经遇到了这个问题并知道解决方案?

5 个解决方案

#1


36  

After upgrading to OS 10.9 I run into same issue. Try installing command line developer tools

升级到操作系统10.9后,我遇到了同样的问题。尝试安装命令行开发工具。

run

运行

xcode-select --install

#2


8  

Here is how I solved this after installing Xcode:

下面是我在安装Xcode后如何解决这个问题:

cd /usr/include
sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/php

#3


1  

If the solution by Janis Lankovskis did not work out.. then it seems like your PHP installation is weirdly broken..

如果Janis Lankovskis的解决方案没有成功。然后,似乎你的PHP安装被奇怪地破坏了。

How did you install PHP in the first place?

您是如何首先安装PHP的?

The main problem here is the phpize command, which seems to exist but if failing miserably (I don't know why pecl continues.. that seems weird).

这里的主要问题是phpize命令,它似乎存在,但如果失败了(我不知道为什么pecl会继续)。这似乎是奇怪的)。

I'd re-install PHP, and make sure the header files are available - and in case you have multiple installations then make the path of the phpize command for your "currently active" PHP installation the first path in your $PATH

我将重新安装PHP,并确保头文件是可用的——如果您有多个安装,那么您可以将phpize命令的路径用于您的“当前活动”PHP安装,这是您的$ path中的第一个路径。

#4


0  

I found this article very helpful. Saved a lot of time after I wasted a lot of time to check other links.

我觉得这篇文章很有帮助。在我浪费了很多时间检查其他链接之后,我节省了很多时间。

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.

这是MAMP不附带所有PHP源来编译pecl mongo文件并创建mongoso。你所需要的就是下载你正在使用的相应版本的php。我使用的是php版本5.6.10。我检查了php.net站点,它的版本是5.6.13。我从PhP.net下载了这个版本的源代码。被执行的“sudo pecl安装mongo”再次成功。

#5


0  

This worked for me:

这工作对我来说:

$ brew tap homebrew/php
$ brew install php56-mongodb

Then add this to your php.ini

然后把这个添加到你的php。ini中。

extension='/usr/local/opt/php56-mongodb/mongodb.so'

扩展= / usr /地方/ opt / php56-mongodb / mongodb.so '

Notice that I am installing "php56-mongodb" and also linking to the same on php.ini. You can change that to your preferred php version.

请注意,我正在安装php56-mongodb,并在php.ini上链接到相同的内容。您可以将其更改为首选的php版本。

#1


36  

After upgrading to OS 10.9 I run into same issue. Try installing command line developer tools

升级到操作系统10.9后,我遇到了同样的问题。尝试安装命令行开发工具。

run

运行

xcode-select --install

#2


8  

Here is how I solved this after installing Xcode:

下面是我在安装Xcode后如何解决这个问题:

cd /usr/include
sudo ln -sf /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/php

#3


1  

If the solution by Janis Lankovskis did not work out.. then it seems like your PHP installation is weirdly broken..

如果Janis Lankovskis的解决方案没有成功。然后,似乎你的PHP安装被奇怪地破坏了。

How did you install PHP in the first place?

您是如何首先安装PHP的?

The main problem here is the phpize command, which seems to exist but if failing miserably (I don't know why pecl continues.. that seems weird).

这里的主要问题是phpize命令,它似乎存在,但如果失败了(我不知道为什么pecl会继续)。这似乎是奇怪的)。

I'd re-install PHP, and make sure the header files are available - and in case you have multiple installations then make the path of the phpize command for your "currently active" PHP installation the first path in your $PATH

我将重新安装PHP,并确保头文件是可用的——如果您有多个安装,那么您可以将phpize命令的路径用于您的“当前活动”PHP安装,这是您的$ path中的第一个路径。

#4


0  

I found this article very helpful. Saved a lot of time after I wasted a lot of time to check other links.

我觉得这篇文章很有帮助。在我浪费了很多时间检查其他链接之后,我节省了很多时间。

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.

这是MAMP不附带所有PHP源来编译pecl mongo文件并创建mongoso。你所需要的就是下载你正在使用的相应版本的php。我使用的是php版本5.6.10。我检查了php.net站点,它的版本是5.6.13。我从PhP.net下载了这个版本的源代码。被执行的“sudo pecl安装mongo”再次成功。

#5


0  

This worked for me:

这工作对我来说:

$ brew tap homebrew/php
$ brew install php56-mongodb

Then add this to your php.ini

然后把这个添加到你的php。ini中。

extension='/usr/local/opt/php56-mongodb/mongodb.so'

扩展= / usr /地方/ opt / php56-mongodb / mongodb.so '

Notice that I am installing "php56-mongodb" and also linking to the same on php.ini. You can change that to your preferred php version.

请注意,我正在安装php56-mongodb,并在php.ini上链接到相同的内容。您可以将其更改为首选的php版本。