If you need to install PHP PDO mysql extension on Debian, its very
simple. This is what I did to get it done for both MySQL or MariaDB extensions for the lastest PHP version:
In case you need the PostgreSQL extension, use:
These packages now provide PDO extensions, no need for any additional steps.
For Debian Lenny or PHP 5 versions:
If you are still using Lenny or PHP 5, you should strongly consider upgrading your system, mainly for security and performance fixes.
For Debian Lenny and previous versions that don’t include PDO in the php-mysql package, you’ll need to do these additional steps:
Use PECL to install PDO:
sudo pecl install pdo
Then, in case you want the PDO MySQL extension:
sudo pecl install pdo_mysql
I found out that PDO and mysqli drivers conflicted on my Lenny system and I ended up with none. To fix this, do
pecl install mysql and then add
extension=mysql.so on your
php.ini like indicated below.
Then you have to edit
/etc/php5/apache2/php.ini and add:
Also add this line only if you installed pdo_mysql.
Restart your web server with:
sudo service apache2 restart
And that’s it. Enjoy your PDO extensions on Debian Lenny.