I have a site using Apache that is just the following code:
<?php $m = new MongoClient(); ?>
`PHP Fatal Error: Class 'MongoClient' not found`
php -i | grep 'Configuration'
Configuration File (php.ini) Path => /etc/php5/cli | Loaded Configuration File => /etc/php5/cli/php.ini
grep 'mongo' /etc/php5/cli/php.ini
php -i | grep 'extension'
extension_dir => /usr/lib/php5/20121212 => /usr/lib/php5/20121212
ls /usr/lib/php5/20121212/ | grep 'mongo.so'
sudo pear install -f pecl/mongo
sudo pecl install mongo
Class 'MongoClient' not found
The problem was that I was using
php -i | grep 'Configuration' to find the .ini file. This lead to
/etc/php5/cli/php.ini. In retrospect, this should have been an obvious giveaway:
cli means command line interface, basically for the interpreter. What I needed was the ini file that Apache was using.
Unfortunately, there was no great way to do this as I couldn't log into the
www-data user, but I made a file that had the code
<?php phpinfo(); ?>
and that revealed that the .ini file location was actually
Once I updated that ini file with
extension=mongo.so, the module was loaded at startup, so I restarted and everything is working now.