Just contact MongoDB, everything starts from scratch. I've been doing this all afternoon and I've done the installation and sorted it out.
I. Installation of MongoDBI was installed under Linux, and the steps are as follows:
1. Download installation packageBe sure to pay attention to your machine is 32-bit or 64-bit, or down the package can not be used. I started is the wrong package, after the installation of a prompt floating point exception, white toss half a day. Download page http://www.mongodb.org/downloads, you can choose the appropriate version according to the different machine. I downloaded the static-2.5.0,32 bit version.
2. InstallationIn fact, the installation process is very simple, to solve a pressure on the line
Tar xvzf mongodb-linux-i686-static-2.5.0.tgz
3. Starter MongoDBSuppose the unpacked directory is/home/qmhball/mongo,mangodb the associated executable is located in the/home/qmhball/mongo/bin directory. Write a simple configuration file mongod.conf
#数据目录
dbpath =/home/qmhball/mongo/db
port = 9304
bind_ip = 10.1.146.163
#日志目录
logpath =/home/ Qmhball/mongo/log/mongo.log
Logappend = True
#以后台Daemon形式运行服务
fork = True
Perform
Cd/home/qmhball/mongo/bin
./mongod--config mongod.conf
After successful startup, you will see a message similar to the following in the log Wed may 15:53:59.825 [Initandlisten] MongoDB starting:pid=10527 port=9304 dbpath=/home/qmhball /mongo/db 32-bit Host=web
4. Test execution in bin directory
./mongo--host 10.1.146.163--port 9304
Enter interactive mode type Db.test.save ({a:1}) Db.test.find () will get {"_id": ObjectId ("519cebd23c053d9709065602"), "a": 1} Description data has been stored in DB
two. Installation of PHP extensions
1. Download the source code and extractSOURCE Package Address Http://pecl.php.net/get/mongo-1.4.0.tgz
2. InstallationSuppose the extract directory is mongo-1.4.0 into the mongo-1.4.0 directory, followed by:
Phpize
./configure make make
install
After the installation is successful, you will get a hint similar to the following installing shared extensions:/usr/local/lib/php/extensions/no-debug-non-zts-20090626/ In this directory you will find mongo.so
3. Modify PHP configurationJoin in the php.ini
Extension=/usr/local/lib/php/extensions/no-debug-non-zts-20090626/mongo.so
Done. Tips: If you are running under a Web service such as Apache, remember to restart the service, the new extension will take effect.
4. Testdemo.php
<?php $user = Array (' first_name ' => ' MongoDB ', ' last_name ' => ')
Fan ', ' tags ' => array (' Developer ', ' user '));
Configuration $dbhost = ' 10.1.146.163:9304 ';
$dbname = ' Test ';
Connect to test database $m = new Mongo ("mongodb://$dbhost");
$db = $m-> $dbname;
Get the Users collection $users = $db->users;
Insert this new document into the Users collection $res = $users->save ($user);
Var_dump ($res);
$data = $users->findone ();
Var_dump ($data);
Execute, get bool (TRUE) array (4) {["_id"]=> object (mongoid) #7 (1) {["$id"]=> string) 519cf324876d75714cb4 e973 "} [" First_Name "]=> string (7)" MongoDB "[" Last_Name "]=> string (3)" Fan "[" Tags "]=> array (2) { [0]=> string (9) "Developer" [1]=> string (4) "User"}}