This afternoon’s glorious freelance waste of time was debugging a server’s PHP installation which got broken with a experimental installation of iRedMail — do NOT install iRedMail on a production machine, it’s meant for fresh installs only.
iRedMail’s removal script is great… if you want to remove apache, mysql, php, etc. etc. etc. Don’t do it.
That’s my scenario, you may have gotten this error in a different manner. Either way the solution is similar.
I rebooted my Ubuntu 12.04 Linode VPS (referral link) and found my Rails/Passenger sites came up first time, but my WordPress/mysql reliant php sites failed giving this error, or a variant thereof:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
You’ve probably already tried to reinstall your “php5” “php5-mysql” packages already, but found it said they’re correctly installed.
Enter this line to find all packages that are in a “purged” state.
dpkg --get-selections | grep purge
Purged packages are uninstalled but not removed. Which is confusing, as you can’t install over them.
apache2 purge libapache2-mod-php5 purge libaprutil1 purge php5-cli purge php5-common purge php5-imap purge
So you want to remove + reinstall the pertinent packages:
sudo apt-get remove php5-common
and then do the apt-get install command as per your original setup. So for me:
sudo apt-get install libapache2-mod-php5 php-pear php5 php5-cgi php5-cli php5-common php5-curl php5-gd php5-json php5-ldap php5-mcrypt php5-mysql php5-pgsql php5-readline
sudo apachectl restart
Your mileage may vary.