无法在Mac OS 10.9上安装MongoDB PHP驱动程序。

21

在谷歌上搜索了大约一个小时,找不到适合我的解决方案。我使用的是OS X 10.9 Mavericks。

终端显示如下:

$ 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

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


欢迎来到stackoverflow.com。不幸的是,您的问题不适合在这个网站上发布,因为stackoverflow只涉及编程问题。然而,在stackexchange网络中有几个其他网站,您的问题会更加合适。 - Philipp
4
@Philipp,虽然这显然与安装软件有关,但我不同意这个问题不适合在这个网站上提问。毕竟,被安装的软件是为该平台上的开发目的而设计的,对于其他开发者升级到Mac上的Mavericks也非常相关。 - Mick Sear
5个回答

42
升级到OS 10.9后,我遇到了同样的问题。 尝试安装命令行开发者工具 运行
xcode-select --install

21
无法安装该软件,因为它目前无法从软件更新服务器获得。 - Beshoy Girgis
我赞同@JohnJ.Camilleri的观点。在升级到OSX Mavericks后,这对我非常有效。 - chopper
你,我的朋友,是一个神。 - Kell
是的,它在我的OS 10.9.3中解决了我的问题!非常感谢。 - firebear
在我的Yosemite 10.10.1上也解决了。谢谢。 - Ricardo Martins
显示剩余2条评论

10

在安装Xcode之后,这是我如何解决这个问题的:

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

9
ln:./php:操作不允许。 - 0x1gene
3
如果我们收到 "./php: Operation not permitted" 的错误提示,该怎么办? - Hayk Aramyan

1
如果 Janis Lankovskis 的解决方法无效,那么您的 PHP 安装可能出现了奇怪的故障。
您最初是如何安装 PHP 的?
主要问题在于 phpize 命令,它似乎存在但却失败了(我不知道为什么 pecl 继续进行...这似乎很奇怪)。
我建议重新安装 PHP,并确保头文件可用 - 如果您有多个安装,则使您“当前活动”的 PHP 安装的 phpize 命令路径成为 $PATH 中的第一个路径。

0
这对我有用:
$ brew tap homebrew/php
$ brew install php56-mongodb

然后将此添加到您的php.ini文件中

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

注意,我正在安装“php56-mongodb”,并在php.ini上链接到它。您可以将其更改为您喜欢的PHP版本。

0

我发现这篇文章非常有帮助。在检查其他链接浪费了很多时间后,节省了很多时间。

问题是MAMP没有提供所有PHP源代码来编译pecl mongo文件并创建mongo.so。你所需要的就是下载你正在使用的相应版本的php。我正在使用php版本5.6.10。我检查了php.net网站,那里有5.6.13版本。我从PhP.net下载了这个版本的源代码。再次执行"sudo pecl install mongo",它就可以工作了。


该文章的URL已经失效或不再相关。 - CORSAIR

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接