System: centos6.5
MongoDB version: CurrentStable release (3.0.6)
First download MongoDB on the official website
Https://www.mongodb.org/downloads
Select the RHEL6 version under Linux, as determined by the system.
I am downloading a binary package with the file name mongodb-linux-x86_64-rhel62-3.0.5
Put the above file under the/mydata.
Unzip to MONGO folder
[Email protected] mydata]# tar zxvf mongodb-linux-x86_64-rhel62-3.0.5.gz
[Email protected] mydata]# MV mongodb-linux-x86_64-rhel62-3.0.5 MongoDB
Start MONGO
[Email protected] mongodb]#/mydata/mongodb/bin/mongod--dbpath/mydata/mongodata
The following prompt appears to indicate success
2015-09-26t11:01:31.021-0700 I NETWORK [Initandlisten] waiting for connections on port 27017
To launch successfully here, we started to install PHP MONGO extension and test MongoDB
Here in my virtual machine pre-installed with Yum LNMP environment, here to install a MONGO extension is good
PECL Install MONGO
The location of the mongo.so is displayed after the installation is complete.
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20121212/mongo.so '
At this time to see the PHP extension directory is not the same as the above directory, if different need to copy mongo.so to the appropriate directory
Php-i | grep extension
Vim/etc/php.ini
Add extension=mongo.so to last line
Note that it is important to ensure that the php.ini path is the path specified by the PHP configuration file: Execute PHP--ini to view the PHP configuration file path, php.ini copy to the specified path if the current path is not php.ini
Restart PHP-FPM
Service PHP-FPM Restart
Set up a test file called mongotest.php.
<?php $mongo = new MONGO (); $dbs = $mongo->listdbs (); Print_r ($dbs);?>
Visit http://localhost/mongotest.php
Get the following results
To test success here
PHP extension Installation and connection MONGO test