简体   繁体   English

致命错误:sudo pecl install mongodb

[英]Fatal error while: sudo pecl install mongodb

I have problem to install mongodb with pecl.我在使用 pecl 安装 mongodb 时遇到问题。 After sudo pecl install mongodb it's always give mesudo pecl install mongodb之后它总是给我

fatal error: 'php.h' file not found #include致命错误:找不到“php.h”文件#include

1 error generated.产生 1 个错误。 make: *** [php_phongo.lo] Error 1 ERROR: 'make' failed make: *** [php_phongo.lo] 错误 1 ERROR: 'make' 失败

System MacOS Mojave, Xcode was updated系统 MacOS Mojave,Xcode 已更新

Thanks!谢谢!

问题可能是我安装的 PHP 版本比我的 mac 上安装的版本旧,在将终端中的 php 源代码从 MAMP Pro 更改为一个之后,MongoDB 安装没有问题

This happens when we try to install mongodb driver on the default PHP installation on MacOS.当我们尝试在 MacOS 上的默认 PHP 安装上安装 mongodb 驱动程序时会发生这种情况。 To fix this issue we should first change the PHP from default macOS PHP o our installed version.要解决此问题,我们应该首先将 PHP 从默认的 macOS PHP 或我们安装的版本更改。

Run the command: which php to see the PHP being used.运行命令: which php以查看正在使用的 PHP。 If the output is usr/bin/php then it is the default PHP.如果输出是usr/bin/php则它是默认的 PHP。

Then open your bash_profile file, using any code editor, and add the following line to it, where you must provide path to your PHP installation.然后使用任何代码编辑器打开 bash_profile 文件,并向其中添加以下行,您必须在其中提供 PHP 安装路径。

export PATH=/Applications/MAMP/bin/php/php7.3.1/bin:$PATH

In my case it was MAMP's PHP, then run source ~/.bash_profile to load your bash profile changes.就我而言,它是 MAMP 的 PHP,然后运行source ~/.bash_profile以加载您的 bash 配置文件更改。

Now when you will run which php command, you will see the path of your PHP installation.现在,当您运行which php命令时,您将看到 PHP 安装的路径。

Now, if you try to install any PHP module using the pecl command, it should run just fine.现在,如果您尝试使用pecl命令安装任何 PHP 模块,它应该可以正常运行。

Problem is the installer can't find the "php.h file".问题是安装程序找不到“php.h 文件”。 Symlink the file to the desired folder path should work.将文件符号链接到所需的文件夹路径应该有效。

Mac users example: ln -s /opt/homebrew/Cellar/pcre2/10.39/include/pcre2.h /opt/homebrew/Cellar/php@8.0/8.0.16_1/include/php/ext/pcre/pcre2.h Mac 用户示例: ln -s /opt/homebrew/Cellar/pcre2/10.39/include/pcre2.h /opt/homebrew/Cellar/php@8.0/8.0.16_1/include/php/ext/pcre/pcre2.h

Syntax: ln -s <path-to-file> <path-to-be-put>语法: ln -s <path-to-file> <path-to-be-put>

This should work.这应该工作。

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

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