Page 1 of 1

Install PHP MongoDB Driver On NGINX + PHP FPM

Posted: Tue Mar 27, 2018 3:11 am
by admin
Here is the step we install PHP Mongodb Driver on Ubuntu.

1). Install Mongodb Driver via PECL

Code: Select all

sudo pecl install mongodb
This command should output the result below:

Code: Select all

Build process completed successfully
Installing '/usr/lib/php/20151012/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.4.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongodb.so" to php.ini


2). create mongodb mod file

Code: Select all

cd /etc/php/7.0/mods-available
sudo cp mysqli.ini mongodb.ini
sudo vi mongodb.ini
extension=mongodb.so

3). Enable the mongodb mod

Code: Select all

cd /etc/php/7.0/fpm/conf.d
sudo ln -s 20-mongodb.ini /etc/php/7.0/mods-available/mongodb.ini

4). Restart Nginx and PHP FPM

Code: Select all

sudo service nginx restart
sudo service php7.0-fpm restart

Do not forget restart the PHP FPM to enable the new installed mongodb module.