Michał Cywiński
Michał Cywiński

Reputation: 31

Fatal error while: sudo pecl install mongodb

I have problem to install mongodb with pecl. After sudo pecl install mongodb it's always give me

fatal error: 'php.h' file not found #include

1 error generated. make: *** [php_phongo.lo] Error 1 ERROR: 'make' failed

System MacOS Mojave, Xcode was updated

Thanks!

Upvotes: 3

Views: 2458

Answers (3)

Lloyd
Lloyd

Reputation: 1

Problem is the installer can't find the "php.h file". 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/[email protected]/8.0.16_1/include/php/ext/pcre/pcre2.h

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

This should work.

Upvotes: 0

iamabhishek
iamabhishek

Reputation: 447

This happens when we try to install mongodb driver on the default PHP installation on MacOS. To fix this issue we should first change the PHP from default macOS PHP o our installed version.

Run the command: which php to see the PHP being used. If the output is usr/bin/php then it is the default 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.

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.

Now when you will run which php command, you will see the path of your PHP installation.

Now, if you try to install any PHP module using the pecl command, it should run just fine.

Upvotes: 1

Michał Cywiński
Michał Cywiński

Reputation: 31

Problem was probably that I install oldest version PHP than was installed on my mac, after changing php source in terminal to one from MAMP Pro, MongoDB was installed without problems

Upvotes: 0

Related Questions