2013-10-25 144 views
19

谷歌搜索大約一小時後,找不到任何適合我的解決方案。我在OS X 10.9 Mavericks上。無法在mac os上安裝mongodb php驅動程序10.9

這裏是終端說:

$ 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 

也許有人已經遇到了這個問題,並知道解決的辦法?

+0

歡迎來到stackoverflow.com。不幸的是你的問題不適合這個網站,因爲stackoverflow只是關於編程問題。然而,還有其他幾個網站的堆棧交換網絡,你的問題會更合適。 – Philipp

+1

@ Philipp,儘管這顯然與安裝軟件有關,但我不同意這個問題不適合本網站。畢竟,安裝的軟件將用於該平臺的開發目的,並且與其他開發人員在Mac上升級到Mavericks非常相關。 –

回答

36

升級到OS 10.9後,我遇到了同樣的問題。 嘗試安裝命令行開發工具

運行

xcode-select --install 
+19

「無法安裝該軟件,因爲它目前不能從軟件更新服務器獲得。「 –

+0

正是我需要 - 這應該是一個公認的答案! –

+0

我第二@JohnJ.Camilleri。這升級到OSX小牛隊後完全適合我 – chopper

8

這是我如何解決這個安裝後的Xcode:

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

這對我有效,謝謝! – peelman

+0

像一個魅力工作 – Ehtesham

+8

ln:./php:不允許的操作 – 0x1gene

1

如果詹尼斯Lankovskis解決沒有工作了..然後它好像你的PHP安裝被奇怪地破壞了。

你是怎麼在第一個地方安裝PHP的?

這裏的主要問題是phpize命令,這似乎存在,但如果失敗悲慘(我不知道爲什麼pecl繼續..這似乎很奇怪)。

我想重新安裝PHP,並確保頭文件可用 - 並且如果您有多個安裝,請爲您的「當前活動」PHP安裝創建phpize命令的路徑作爲第一個路徑路徑

0

我找到了this article very helpful。浪費了很多時間檢查其他鏈接後,節省了很多時間。

事情是MAMP不附帶所有PHP源代碼來編譯pecl mongo文件並創建mongo.so。所有你需要的是下載你正在使用的相應版本的php。我使用的是PHP版本5.6.10。我檢查了有​​版本的php.net網站。我從PhP.net下載了此版本的源代碼。再次執行「sudo pecl install mongo」並且工作。

0

這爲我工作:

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

然後添加到您的php.ini

延長= '在/ usr /本地的/ opt/php56-MongoDB的 /mongodb.so'

請注意,我正在安裝「php56-mongodb」並鏈接到php.ini上。您可以將其更改爲您首選的PHP版本。

相關問題