Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

mongodb

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.

like image 249
Roman Avatar asked Nov 08 '11 14:11

Roman


2 Answers

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.

like image 163
VolkerK Avatar answered Oct 26 '22 11:10

VolkerK


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

like image 41
Rajendra Avatar answered Oct 26 '22 11:10

Rajendra