mac下PHP安装mongo扩展

说明:mongo 和 mongodb是两个扩展,目前mongo扩展已经被废弃,建议使用mongodb扩展,但对于一些老项目还在使用mongo扩展的,请参考此文。

mongodb和其他PHP扩展的安装方法类似。

系统:MacOS 10.12.6,MxSrvs集成包:(之前用MacOS 10.14安装的时候,出现了各种问题,因此降级系统到10.12,感觉比10.14好用。

降级教程参考:https://www.cnblogs.com/rxbook/p/10987206.html

从这里下载扩展包:http://pecl.php.net/package/mongo

如果安装mongodb扩展,从这里下载:http://pecl.php.net/package/mongodb

准备工作(如果已经安装了autoconf和openssl请跳过这个步骤):

brew install autoconf
brew install openssl
echo
'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"

解压,进入:

/Applications/MxSrvs/bin/php/bin/phpize
./configure --with-php-config=/Applications/MxSrvs/bin/php/bin/php-config --with-openssl-dir=/usr/local/Cellar/openssl/1.0.2r
make && make install

 

编辑php.ini,在extension区域添加mongodb扩展

extension=/Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20131226/mongo.so

查看phpinfo()

 

posted @ 2019-06-10 20:44  码农骆驼  阅读(3587)  评论(0编辑  收藏  举报