CentOS Yum installation MongoDB and PHP extensions _mongodb

Source: Internet
Author: User
Tags install php install mongodb mongodb mongodb server php mongodb

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 
) 
* * 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.