PHP MongoDB extension / class problems with CLI only

  • cd / etc / php5
  • apache2/php.ini and cli/php.ini identical
  • apache2/conf.d/mongo.ini and cli/conf.d/mongo.ini identical

The mongo extension does not load when I try to execute a script command through the command line (I get an error not found by the class). Works fine through apache.

Any ideas? (I wrote this tiny script for verification):

 <?php echo class_exists('Mongo') ? "Mongo class found" : "Mongo class not found" . PHP_EOL; ?> 

When this file gets through apache, it echoes affirmative denial through the CLI.

+4
source share
1 answer

Most likely you are using the wrong php file. Use php --ini to see which ones are loading. You can also set php.ini settings display_errors=1 and display_startup_errors=1 to understand why its reason could not be loaded.

+5
source

Source: https://habr.com/ru/post/1414825/


All Articles