Installing the PHP 7 MongoDB Client/Driver?

后端 未结 12 945
日久生厌
日久生厌 2020-11-28 06:17

I am very eager to start working with PHP 7 however one issue is getting in the way... I primarily use MongoDB for the database, and the problem is that I don\'t know how to

12条回答
  •  旧巷少年郎
    2020-11-28 06:44

    How to connect php 7.0 with MongoDB in ubuntu 16.04 lts?

    1)Install LAMP using the following link. It installs Apache2, mysql and php 7.0. https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

    2)Install the MongoDB community Edition on Ubuntu using the steps in the following link. http://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

    3)Type the following command to get the mongoDB extension from pecl

    sudo apt install php-pear
    

    4)Add the following to the php.ini file at /etc/php/apache2/7.0

    extension=mongodb.so
    

    Important - The classes have been changed too:

    new MongoClient();  //Old Class
    
    new MongoDB\Driver\Manager(); // New Class
    

    Refer - http://php.net/manual/en/set.mongodb.php

提交回复
热议问题