Working with Ubuntu 12.04 here, nginx and php5-fpm

I had mongo working well on php 5.3, then I added the ondrej/php5 ppa and updated to php5.4. It kept GD and CURL extensions, but not mongo. I re-added the line to the php.ini file, and nothing. Then I enabled startup errors and got this:

PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/mongo.so' - /usr/lib/php5/20100525/mongo.so: cannot open shared object file: No such file or directory

So, wild guess, I did find -name 'mongo.so' and moved the file from 20090626/ to 20100525/ ...which resulted in this error:

PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20090626
PHP    compiled with module API=20100525
These options need to match

I then did pecl uninstall mongo and pecl install mongo - which created the new mongo.so file right back in 20090626/

I'm kinda new to all this so hopefully this is a blind easy mistake to fix! I just need to get mongo back up and running.


My guess would be either:

  • pecl install mongo is actually installing a pre-built binary (which would be really dumb, but wouldn't be nearly as surprising); or
  • You've still got the old php5-dev package from your 5.3 installation sitting around, and pecl is finding and using that instead of the 5.4 version. Take a look at your PHP-related packages list (dpkg -l '*php*') and see if there's any 5.3 packages left, and upgrade them.
| improve this answer | |
  • I was just answering my own question with this! Thanks! – kavisiegel Jul 12 '12 at 6:22
  • So which one was it? – womble Jul 12 '12 at 6:24
  • 2
    I had to update php5-dev, uninstall mongo then reinstall. – kavisiegel Jul 12 '12 at 6:26
  • that worked perfectly for me – Oliver Bayes-Shelton Jun 18 '15 at 13:57

Great minds think alike, womble posted moments after I figured out what's going on. His answer is correct and before mine so it's what I'll accept as the answer, but for future reference, the solution was this:

apt-get update
apt-get install php5-dev
pecl uninstall mongo
pecl install mongo
/etc/init.d/php5-fpm restart

And of course, mongo.so was already in the php.ini in a way that pecl didn't remove it, so that made it slightly easier to upgrade.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.