简体   繁体   中英

unable to load mongo extension for php

After trying for two days to get this to run;

sudo pecl install mongo

I finally got it done and added the extension to php.ini only to find out that it will not work for me.

This is what the install output was at the end;

Libraries have been installed in:
/tmp/pear/temp/pear-build-rootVYRzXc/mongo-1.5.8/modules

running: make INSTALL_ROOT="/tmp/pear/temp/pear-build-rootVYRzXc/install-mongo-1.5.8" install
Installing shared extensions:     /tmp/pear/temp/pear-build-rootVYRzXc/install-mongo-1.5.8/usr/lib/php5/20090626/

Installing '/usr/lib/php5/20090626/mongo.so'
install ok: channel://pecl.php.net/mongo-1.5.8
# I edited etc/php54/php.ini here
sudo service apache2 restart
php --ri mongo
Extension 'mongo' not present.

But when I did mongo --version I get MongoDB shell version: 1.4.4 which may be from my modulus installation. Could that cause mongo not to load?

When trying;

$mongoConn = new MongoClient("mongodb://<user>:<pass>@proximus.modulusmongo.net:27017");

I get;

Fatal error: Class 'MongoClient' not found

Verify that mongo.so is found on in extension_dir:

php -i | grep extension_dir

Then cd to that folder and check for presence of mongo.so.

If present, make sure you have this in php.ini

extension=mongo.so

If this does not work: In certain virtual systems, such as those based on Docker, you may need to install your extension as the user associated with the "domain" or instance. A global (root user) installation may not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM