简体   繁体   中英

Can't get mongo.so extension to load after updating PHP to 5.3

I had PHP 5.2 with MongoDB installed on Debian Lenny x64 and everything was fine.

After updating PHP to 5.3 (dotdeb) I can't get MongoDB to work, I always get an error

Fatal error: Class 'Mongo' not found (...)

Everything else works fine, all default modules are working.

My php.ini:

extension_dir = "/usr/lib/php5/20090626"
extension=mongo.so

Mongo.so is in same location as written above. But when I run php -m in console to check loaded modules, "mongo" isn't listed there.

I can't use dl('mongo.so') to load module at runtime, because this function was deprecated in PHP 5.3.

May be I should recompile mongo somehow, I just don't know how to do that because I'm not very good in *nix commands.

Thanks for your help!

UPDATE Also may be it's worth saying that before my mongo.so was in /usr/lib/php5/20060613 and I manually copied it to "/usr/lib/php5/20090626" because it seems that after updating my PHP all modules are located there.

The extension module api has changed between php5.2 and php5.3. When php tries to load an extension module both sides have to "present" an api magic key that identifies the api version. If those numbers don't match the module is not loaded/activated.

Try sudo pecl install mongo again to get an extension module that fits your new php version.

Try re installing mongo & restart service

sudo pecl uninstall mongo 
sudo pecl install mongo
sudo service apache2 restart

This will install mongo in to newer version

I spent a little time trying to fix this, I am guessing you had a previous mongo install. The way I fixed it was by:

I installed php5-dev:

sudo apt-get install php5-dev
cd /etc/php5/apache2/conf.d/
sudo rm -rf mongo.ini

I then viewed my php.ini and removed extension=mongo.so

Then:

sudo pecl uninstall mongo 
sudo pecl install mongo
sudo service apache2 restart 

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