One, install mongodb,php extension
[Root@localhost ~]# yum install Php-pecl-mongo MongoDB mongodb-devel mongodb-server
PHP extensions, MongoDB server, MongoDB customers installed.
Second, configure/etc/mongodb.conf
[Root@localhost www]# cat/etc/mongodb.conf |awk ' {if ($!~/^$/&& $!~/^#/) {print $}} '
logpath=/var/log/ Mongodb/mongodb.log//Log position
fork = true //background run
logappend=true //append log
port = 27017 //Port
Dbpath=/var/lib/mongodb //database path
pidfilepath=/var/run/mongodb/mongodb.pid//pid path
It's basically all configured, but why didn't you create the/var/lib/mongodb folder when Yum was installed?
[Root@localhost lib]# mkdir-p/var/lib/mongodb [root@localhost lib]# chown mongodb:mongodb-r/var/lib/mongodb/
Third, start the MongoDB server and view
[Root@localhost www]#/etc/init.d/mongod started
//view
[root@localhost www]#
netstat-tpnl|grep 27017 TCP 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 4641/mongod
So the MongoDB will be able to move normally.
See if the PHP extensions are loaded,
MongoDB PHP Extension
Iv. Test PHP MongoDB Extensions
<?php
$mongo = new MONGO ();
$dbs = $mongo->listdbs ();
Print_r ($dbs);
/** Result:
Array ([
databases] => array
([
0] => array
(
[name] => admin
[Sizeondisk] => 1
[Empty] => 1
)
[1] => Array
(
[name] => local
[Sizeondisk] => 1
[empty] => 1
)
[totalsize] => 0
[OK] => 1
)
* *