Categories
GNU/Linux Free Software & Open Source Programming & Web Development

How to install PHP PDO extensions on Debian

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:

sudo apt-get install php-mysqlCode language: JavaScript (javascript)

In case you need the PostgreSQL extension, use:

sudo apt-get install php-pgsqlCode language: JavaScript (javascript)

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:

extension=pdo.so

Also add this line only if you installed pdo_mysql.

extension=pdo_mysql.so

Restart your web server with:

sudo service apache2 restart

And that’s it. Enjoy your PDO extensions on Debian Lenny.

By Gabriel Saldaña

Gabriel Saldaña is a web developer, photographer and free software advocate. Connect with him on and Twitter

5 replies on “How to install PHP PDO extensions on Debian”

Thanks for that hint but I found out that pdo.so and pdo_mysql.so are available in the lenny packages php-common and php5-mysql. – I think it’s easier to install and update the core packages than using pecl.
sofar|sokai

You also need package libmysqlclient-dev if you want to install with pecl:
apt-get install libmysqlclient-dev

but much easier is to install as sokai pointed.

Hi,
I had problem in Debian Lenny saying “pecl.php.net is using a unsupported protocal – This should never happen.
install failed”

The solution is to delete /usr/share/php/.channels directory and run “pecl update-channels”

Comments are closed.