xcode 在 OS X El Capitan (v10.11.1) 上使用 pecl 安装 Mongodb 驱动程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33483210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using pecl to install the Mongodb driver on OS X El Capitan (v10.11.1)
提问by RobertJoseph
I am trying to install the php mongo driver for OS X. I've tried following these instructionsto no avail.
我正在尝试为 OS X 安装 php mongo 驱动程序。我尝试按照这些说明操作但无济于事。
$ which pecl
-> /usr/local/Cellar/php56/5.6.13_2/bin/pecl
$ which pecl
-> /usr/local/Cellar/php56/5.6.13_2/bin/pecl
$ sudo pecl install mongo
-> full build results herebut the problem the is the error:
$ sudo pecl install mongo
-> 完整的构建结果在这里,但问题是错误:
In file included from /private/tmp/pear/install/mongo/io_stream.c:34:
/private/tmp/pear/install/mongo/contrib/php-ssl.h:33:10: fatal error: 'openssl/evp.h' file not found
#include <openssl/evp.h>
My Xcode command-line tools are up to date (I used $ xcode-select --install
to be sure).
我的 Xcode 命令行工具是最新的(我曾经$ xcode-select --install
确信)。
I'm sure how to fix this problem.
我确定如何解决这个问题。
回答by John J. Camilleri
I managed to get around this by installing OpenSSL using Homebrew (as suggested here):
我设法通过使用 Homebrew 安装 OpenSSL 来解决这个问题(如此处所建议的):
$ brew install openssl
$ brew link openssl --force
Then
然后
$ sudo pecl install mongodb
回答by Uncoke
Do this
做这个
$ cd /usr/local/include
$ ln -s ../opt/openssl/include/openssl
回答by David Wickstr?m
I recommend using http://phpbrew.github.io/phpbrew/for this type of thing. It let's you easily install any extensions to any php version you require.
我建议使用http://phpbrew.github.io/phpbrew/来处理这种类型的事情。它让您可以轻松地将任何扩展安装到您需要的任何 php 版本。
When installing a new version of php, I usually keep an eye on the log while it compiles. There might be dependencies that need installing first. Also, make sure you have an updated version of homebrew installed.
在安装新版本的 php 时,我通常会在编译时关注日志。可能存在需要先安装的依赖项。另外,请确保您安装了更新版本的自制软件。
回答by Alan Cruz
You need to disable the Mac OSX El Capitán rootless mechanism:
您需要禁用 Mac OSX El Capitán rootless 机制:
- Boot with Cmd-R
- Open Terminal
- Type csrutil disable
- Reboot
- 使用 Cmd-R 启动
- 打开终端
- 键入 csrutil 禁用
- 重启
On the Mac, You need to install Xcode, and build the symlink for the openssl comes with Xcode, i.e.
在 Mac 上,你需要安装 Xcode,并为 Xcode 自带的 openssl 构建符号链接,即
cd /usr/include;
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/openssl