可以参考官方:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
需要下载很大包,需要耐心等待。
所有都安装好后,启动mongo服务: 命令行输入:mongod
发现会有error:
dbpath (/data/db/) does not exist
因为mongo默认的数据文件在 /data/db下,
所以此时:
$ mkdir -p /data/db
$ sudo chmod `id -u` /data/db
如果需要安装PHP驱动
首先安装Pear
curl -O http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar
配置Pear
- Type 1 and press return.
-
Enter:
/usr/local/pear
-
Type 4 and press return.
-
Enter:
/usr/local/bin
-
Press return
检验 Pear
pear version
Eventually, if you use any extensions or applications from PEAR, you may need to update PHP’s include path.
最后加入php driver支持(期间也可能报错,需要安装 autorun
命令行输入:brew install automake
然后安装PHP驱动:
sudo pecl install mongo
Open your php.ini file and add to it:
extension=mongo.so
将Mongo加入系统服务:
首先查看一下:
brew info mongo
mongod -f /usr/local/opt/mongodb/mongod.conf --fork
http://stackoverflow.com/questions/8495293/whats-a-clean-way-to-stop-mongod-on-mac-os-x