Search code examples
phpphp-mongodb

Unable to load mongo extension


Suddenly I started getting the following error:

Fatal error: Class 'Mongo' not found in /var/www/html/index.php

What could be the reason? phpinfo() and php -m is not showing mongo extension.

extension=mongo.so is present in correct loaded .ini file.

I even restarted the Apache server, but the problem remains.

phpinfo():
Loaded Configuration File   /etc/php.ini 

/etc/php.ini
extension=mongo.so

It was working earlier and I was able to connect to mongod server by new Mongo().


Solution

  • It appears you have removed the comment on the wrong line, so it made your php.ini unreadable and so Mongo wasn’t loaded.

    If you want to enable error_reporting you should edit that line:

    error_reporting: E_ALL & ~E_NOTICE