Cannot get mongo.so extension to load after upgrading PHP to 5.3

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

After upgrading PHP to 5.3 (dotdeb), I cannot get MongoDB to work, I always get an error

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

Everything else works fine, all modules work by default.

My php.ini:

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

Mongo.so is in the same place as above. But when I run php -m in the console to check the loaded modules, "mongo" is not displayed there.

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

Maybe I need to somehow recompile the mongo, I just don’t know how to do this, because I am not very good at * nix commands.

Thanks for your help!

UPDATE It might also be 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 like after updates of my php all modules are there.

+6
source share
3 answers

The api extension module has changed between php5.2 and php5.3. When php tries to load the extension module, both parties must “present” the magic key api, which identifies the version of api. If these numbers do not match, the module will not load / not activate.

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

+6
source

Try reinstalling mongo and restarting the service

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

This will install mongo in a newer version.

+2
source

I spent a little time trying to fix this, I assume you had a previous installation of mongo. The way I fixed this was:

I installed php5-dev:

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

Then I looked at my php.ini and deleted extension=mongo.so

Then:

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

Source: https://habr.com/ru/post/901029/


All Articles