pecl install mongo - keeps compiling with wrong module API

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.

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.