MongoDB的安裝及在PHP中的配置----Windows版

1,下載mongodb壓縮包http://downloads.mongodb.org/win32/mongodb-win32-i386-2.0.4.zipphp

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

相關文章
相關標籤/搜索