安裝mongodb外掛程式

來源:互聯網
上載者:User

標籤:class   filter   app   php-fpm   安裝   測試   test   get   highlight   

1、安裝mngodb模組
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、檢查模組是否存在
cd /application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/ls mongodb.so   mongodb.so
3、修改 php.ini
vim /application/php/lib/php.ini ... extension=redis.so    #添加此行 ...
4、重啟php-fpm5、測試連接mongodb,訪問頁面正常,表示串連成功
<?php$manager = new MongoDB\Driver\Manager("mongodb://127.0.0.1:27017");$bulk = new MongoDB\Driver\BulkWrite;$bulk->insert([‘x‘ => 1, ‘class‘=>‘toefl‘, ‘num‘ => ‘18‘]);$bulk->insert([‘x‘ => 2, ‘class‘=>‘ielts‘, ‘num‘ => ‘26‘]);$bulk->insert([‘x‘ => 3, ‘class‘=>‘sat‘, ‘num‘ => ‘35‘]);$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->executeQuery(‘test.log‘, $query);foreach ($cursor as $document) {    print_r($document);}

  

 

 

 

  

 

安裝mongodb外掛程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.