Installing the MongoDB Plugin

Source: Internet
Author: User

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

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.