简体   繁体   中英

PHP MongoClient Class not found after installation

I am using the MongoClient class to access a MongoDB.

$mongo = new MongoClient($conset['host'] . ":" . $conset['port'],$conset['host']);

I get the fatal error Fatal error: Class 'MongoClient' not found I installed the Mongo client using pear's pecl install mongo and then add extension=mongo.so to the php.ini . I restart my apache server and check to see if mongo is installed using pecl search mongo which returns mongo 1.5.5 (stable) 1.5.5 MongoDB database driver

However when I run the same php script it still returns the Fatal error. Why is this happening and how do I fix it?

EDIT: I just called my VPS host (OVH) and they verified that they do not block any scripts or php extensions.

After Stennie's comment I tried some things. In the end, I stopped my apache2 server, edited the php.ini file, then started (this worked).

I think before, when the apache2 server stopped, the php.ini got overwritten with content so the extension=mongo.so was lost.

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