brew安装mongodb及php mongodb扩展

背景

安装某laravel项目

参考

http://old.ruesin.com/system/mac/mac-mongodb-345.html

安装mongodb服务

1
brew install mongodb
1
2
3
4
5
6
7
8
9
10
==> Installing mongodb
==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.4.10.high_sierra.
######################################################################## 100.0%
==> Pouring mongodb-3.4.10.high_sierra.bottle.tar.gz
==> Caveats
To have launchd start mongodb now and restart at login:
brew services start mongodb
Or, if you don't want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
==> Summary

php 的 mongodb 扩展

search一下

1
brew search mongo
1
brew install php71-mongo

安装出错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
NOTICE: PHP message: PHP Warning:  PHP Startup: mongodb: Unable to initialize module
Module compiled with build ID=API20160303,NTS
PHP compiled with build ID=API20160303,NTS,debug
These options need to match
in Unknown on line 0
<br />
<b>Warning</b>: PHP Startup: mongodb: Unable to initialize module
Module compiled with build ID=API20160303,NTS
PHP compiled with build ID=API20160303,NTS,debug
These options need to match
in <b>Unknown</b> on line <b>0</b><br />
Unknown(0) : Warning - PHP Startup: mongodb: Unable to initialize module
Module compiled with build ID=API20160303,NTS
PHP compiled with build ID=API20160303,NTS,debug
These options need to match


网上搜是需要重新安装编译

1
brew reinstall <formulaname> --build-from-source