1. Installing the Mngodb module
wget Http://pecl.php.net/get/mongodb-1.2.4.tgztar zxf mongodb-1.2.4.tgzcd mongodb-1.2.4/application/php/bin/phpize ./configure--with-php-config=/application/php/bin/php-configmakemake Install Installing shared extensions: /application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/
2, check whether the module exists
Cd/application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/ls mongodb.so mongodb.so
3, modify the php.ini
Vim/application/php/lib/php.ini ... extension=redis.so #添加此行 ...
4, restart PHP-FPM5, test connection MongoDB, access to the page is normal, indicating successful connection
<?php$manager = new Mongodb\driver\manager ("mongodb://127.0.0.1:27017"); $bulk = new mongodb\driver\bulkwrite;$ Bulk->insert ([' x ' = + 1, ' class ' = ' TOEFL ', ' num ' + ') '); $bulk->insert ([' x ' + = 2, ' class ' + ' IELTS ', ' num ' = ' + ']); $bulk->insert ([' X ' = 3, ' class ' + ' sat ', ' num ' = ') '); $manager Executebulkwrite (' Test.log ', $bulk); $filter = [' x ' = = [' $gt ' + 1]]; $options = [ ' projection ' = ' = ' _id ' = 0], ' sort ' = = [' x ' = 1],]; $query = new Mongodb\driver\query ($filter, $options); $cursor = $manager->execut Equery (' Test.log ', $query); foreach ($cursor as $document) { print_r ($document);}
Installing the MongoDB Plugin