MySQL extension of PHP not working

This probably isn't a configuration issue. I'm not familiar with how things are done in Debian (regarding upgrading/downgrading PHP) but it seems the PHP used by Apache and the PHP CLI are in fact using different PHPs.

You can verify this by doing a phpinfo() from browser and a php -i on the commandline. If Apache and CLI are using the same PHP, the results should be exactly the same (same configure options, compile time, libraries enabled, etc.).