I am trying to install the MongoDB PHP Extension in my new MacBook Air M1. I am facing the following error during installation
The command I am using for installation
sudo pecl install mongodb
The error I am facing
/opt/homebrew/Cellar/php/8.0.9/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
^~~~~~~~~
1 error generated.
make: *** [php_phongo.lo] Error 1
ERROR: `make' failed
Here is the output of which php
and which pecl
command
aniketmagadum@Anikets-MacBook-Air bin % which php
/opt/homebrew/bin/php
aniketmagadum@Anikets-MacBook-Air bin % which pecl
/opt/homebrew/bin/pecl
The PHP Version I am using
aniketmagadum@Anikets-MacBook-Air bin % php -v
PHP 8.0.9 (cli) (built: Jul 29 2021 08:52:24) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
aniketmagadum@Anikets-MacBook-Air bin %
My Answer:
It looks like the installation is failing because the 'pcre2.h' header file is not found. You can try installing the PCRE2 library using Homebrew to resolve this issue.
You can install PCRE2 using the following command:
brew install pcre2
After installing PCRE2, try installing the MongoDB PHP Extension again using the following command:
sudo pecl install mongodb
This should resolve the issue and successfully install the MongoDB PHP Extension on your MacBook Air M1.
Rate this post
5 of 5 based on 5721 votesComments