First, install PHP MONGO extension
# wget Https://github.com/mongodb/mongo-php-driver-legacy/archive/master.zip-O/usr/local/src/mongo_php.zip
# Unzip Mongo_php.zip
# CD Mongo-php-driver-legacy-master
#/usr/local/php/bin/phpize
#./configure--with-php-config=/usr/local/php/bin/php-config
# make
# make Install
Second, configure PHP Add extension module
# Vim/usr/local/php/etc/php.ini Add
Extension = mongo.so
Check if Add is successful
#/usr/local/php/bin/php-m | grep MONGO
Restart PHP-FPM
#/etc/init.d/php-fpm Restart
Add a PHP script to the Nginx published Web site Directory with the following content:
# Vim mongo.php
<?php
$m = new Mongoclient ();
echo "Connection to database successfully";
$db = $m->ceshi;
echo "Database Ceshi selected";
?>
Then visit: http://www.test.com/mongo.php
The following message appears stating that the configuration was successful
Connection to database successfully database Ceshi selected
PHP Connection MongoDB