The MongoDB PHP extension supports PHP 5.4, 5.5, 5.6, 7.0, and 7.1.
Installing the MongoDB Extension
To install this extension, run the following commands as your server's root user:
sudo apt-get install gcc make autoconf libc-dev pkg-config sudo apt-get install libssl-dev sudo peclX.Y-sp install mongodb
Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:
sudo bash -c "echo extension=mongodb.so > /etc/phpX.Y-sp/conf.d/mongodb.ini" sudo service phpX.Y-fpm-sp restart
Verify the Installation
You can verify the MongoDB extension is installed by running this command:
phpX.Y-sp -i | grep -i mongodb
You should see output such as the following:
/etc/phpX.Y-sp/conf.d/mongodb.ini, mongodb mongodb support => enabled mongodb version => 1.1.8 mongodb stability => stable mongodb.debug => no value => no value
Using the MongoDB PHP Library
Once you've installed the mongodb PHP extension, the easiest way to use the extension is through the MongoDB PHP library.
See the PHP documentation for a tutorial on using the MongoDB PHP library.
Removing the Deprecated mongo PHP Extension
If you previously installed the older mongo extension (the mongo extension is different than the mongodb extension), you can remove it with the following commands run as root:
sudo rm /etc/phpX.Y-sp/conf.d/mongo.ini sudo service phpX.Y-fpm-sp restart
Alert: For Control Panel Help & Tutorials, click here: Panel Tutorials