Search code examples
phpmongodbcommand-line-interfacefpm

MongoDB PHP Driver not loaded in fpm - but loaded in cli


The system and tools installed on are the following ones:

  • Linux server Ubuntu 16.04.1 LTS
  • php7.0
  • mongoDB version v3.2.12
  • mongoDB php driver 1.2.5.

And I have carefully added extension=mongodb.so in both /etc/php/7.0/fpm/php.ini and /etc/php/7.0/cli/php.ini.

Then I have a document info.php which contains <?php phpinfo(); ?>

So php -f info.php return that mongoDB is correctly loaded, and I can instantiate the various classes and play with them.

But if load the file into a web browser www.myserver.com/info.php, I cannot find the mongoDB section. And indeed all mongoDB-PHP-driver code fails.

Is it because MongoDB-php-driver is not correctly installed for the php/fpm ? Or is it because MongoDB itself is not correctly installed ?

Thanks a lot


Solution

  • sudo systemctl restart php7.0-fpm.service to restart.