1,下载mongodb压缩包http://downloads.mongodb.org/win32/mongodb-win32-i386-2.0.4.zip;php
2,解压到指定目录,例如:c:\mongo;git
3,启动mongodb。首先,须要创建两个目录,一个是日志目录c:\mongo\logs\logs.log,一个是存放数据文件的目录c:\mongo_data,而后打开cmd命令行,进入到c:\mongo\bin\目录下,而后输入以下命令启动服务,c:/mongo/bin>mongod.exe --dbpath c:/mongo_data,显示:github
C:\mongo\bin>mongod --dbpath c:\mongo_data Wed Apr 11 12:23:38 Wed Apr 11 12:23:38 warning: 32-bit servers don't have journaling enabled by def ault. Please use --journal if you want durability. Wed Apr 11 12:23:38 Wed Apr 11 12:23:38 [initandlisten] MongoDB starting : pid=4756 port=27017 dbpat h=c:\mongo_data 32-bit host=20111027-1247 Wed Apr 11 12:23:38 [initandlisten] Wed Apr 11 12:23:38 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data Wed Apr 11 12:23:38 [initandlisten] ** see http://blog.mongodb.org/post/13 7788967/32-bit-limitations Wed Apr 11 12:23:38 [initandlisten] ** with --journal, the limit is lower Wed Apr 11 12:23:38 [initandlisten] Wed Apr 11 12:23:38 [initandlisten] db version v2.0.4, pdfile version 4.5 Wed Apr 11 12:23:38 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506 cb21f8ebf Wed Apr 11 12:23:38 [initandlisten] build info: windows sys.getwindowsversion(ma jor=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST_LIB _VERSION=1_42 Wed Apr 11 12:23:38 [initandlisten] options: { dbpath: "c:\mongo_data" } Wed Apr 11 12:23:38 [initandlisten] waiting for connections on port 27017 Wed Apr 11 12:23:38 [websvr] admin web console waiting for connections on port 2 8017
表示启动成功,最后两行说明的数据库端口和Web端口,默认分别是27017和28017,在浏览器中打开http://localhost:28017,能够看到其相关的一些信息。 能够经过添加参数--port的方式,来修改数据库端口:c:/mongo/bin>mongod.exe --port 10001 --dbpath c:/mongo_dataweb
4,为了方便起见,能够把mongodb的启动方式加入到windows服务中。方法是:C:\mongo\bin>mongod --logpath c:/mongo/logs/logs.log --logappend --dbpath c:/mongo_data --directoryperdb --serviceName MongoDB --install,便可。而后在服务里,就会看到MongoDB,这个服务项了。mongodb
5,MongoDB的windows下的安装就是这样。若是在php中想使用mongodb的话,还得须要下载php的mongodb插件,http://cloud.github.com/downloads/mongodb/mongo-php-driver/php_mongo-1.2.10.zip,解压到php的ext目录中,而后修改php.ini,添加extension=php_mongo.dll,重启apache就OK了。这样你的PHP里就能够使用MongoDB了。shell