Debian 8 - Install MongoDB PHP Driver
Install pear and the php dev tools necessary for compiliation if you haven't already.
sudo apt-get install php5-dev php5-cli php-pear -y
Install the mongo driver
sudo pecl install mongo
This will ask you inf you want to install Enterprise authentcation and the default is 'no';
Add the extension to the php.ini files by running the script below with BASH. This assumes you are using apache.
#!/bin/bash SEARCH='; If you wish to have an extension loaded automatically, use the following' REPLACE='extension=mongo.so\n; If you wish to have an extension loaded automatically, use the following' FILEPATH="/etc/php5/apache2/php.ini" CLI_FILEPATH="/etc/php5/cli/php.ini" sudo sed -i "s:$SEARCH:$REPLACE:" $FILEPATH sudo sed -i "s:$SEARCH:$REPLACE:" $CLI_FILEPATH # Restart Apache to take effect sudo service apache2 restart
Check Driver Version
php --ri mongo | grep Version
Last updated: 16th September 2021
First published: 16th August 2018
First published: 16th August 2018