MongoDB - PHP7.3: How to install MongoDB with PHP 7.3.x on a Mac Catalina 10.15.x OS with Homebrew
The usual command to install mongoDB which is as below:
pecl install mongodb
However, this will fail on MAC Catalina OS with PHP 7.3.x with following error:
Optional steps:
In case you still face issues with mongoDB installation then perform below and try the pecl install mongodb command again -- Download XCode 12 beta CLI tools and XCode 12 beta from https://developer.apple.com/xcode/resources/
In file included from /usr/local/Cellar/php@7.3/7.3.23/include/php/Zend/zend.h:335: /usr/local/Cellar/php@7.3/7.3.23/include/php/Zend/zend_operators.h:486:10: error: 'asm goto' constructs are not supported yet __asm__ goto(In order to fix this error, you will need to do below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Uninstall PHP7.3 and then reinstall it from Source, take necessary backups before performing below steps:
brew update && brew upgrade
brew uninstall php@7.3
brew install --build-from-source php@7.3
brew unlink php@7.0 && brew link --force --overwrite php@7.3
#Add below lines in zshrc or bash_profile of your system
sudo vi ~/.zshrc
export PATH="/usr/local/opt/php@7.3/bin:$PATH"
export PATH="/usr/local/opt/php@7.3/sbin:$PATH"
esc+:wq! #To Save the new changes
source ~/.zshrc
#HTTPD changes. Make below changes in your httpd.conf, you can get the path from httpd -V
sudo vi /usr/local/etc/httpd/httpd.conf
LoadModule php7_module /usr/local/opt/php@7.3/lib/httpd/modules/libphp7.so
esc+:wq! #To Save the new changes
brew services restart httpd
brew install mongodb/brew/mongodb-community
brew services start mongodb-community
pecl install mongodb
#To check successful installation run below:
mongo --help
Optional steps:
- In case you do not have homebrew installed you can install it with this command:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Comments
Post a Comment