I had recently purchased a small computer to act as my development server but I also wanted it to act as second desktop machines. I have plenty of experience using Debian as a server, but I decided to try the new distribution from Ubuntu.
The install was pretty easy including getting PHP 5.1.2, Apache 2, and MySQL 5 installed using the familiar apt-get command. (I wish they had included php 5.1.4, but this wasn’t a deal breaker)
I was dismayed to find that they didn’t have a package for PDO extension (PHP Database Objects). So I installed the PDO via the pecl command:
bhiv@devserver:~# pecl install pdo
It downloaded, phpized, configured, compiled and installed just fine. The only thing I had to do was add the line:
extension=pdo.so
to the files:
/etc/php/apache2/php.ini
/etc/php/cli/php.ini
(and restart apache)
But what good was the PDO without a driver for a database, in my case MySQL. So I tried:
bhiv@devserver:~# pecl install pdo_mysql
It downloaded, phpized, then failed on the configure command with the error:
configure: error:
You’ve configured extension pdo_mysql, which depends on extension pdo,
but you’ve either not enabled pdo, or have disabled it.
After trying a number of ways to force it to install, trying to foce the dotdeb distribution to install I found the simplest solution was to manually download the package with the following commands:
bhiv@devserver:~# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
bhiv@devserver:~# tar zxvf PDO_MYSQL-1.0.2.tgz
bhiv@devserver:~# cd PDO_MYSQL-1.0.2
bhiv@devserver:~# phpize
bhiv@devserver:~# vi configure
comment out lines 4163-4173
bhiv@devserver:~# ./configure
bhiv@devserver:~# make
bhiv@devserver:~# sudo make install
add the lines:
extension=pdo.so
extension=pdo_mysql.so
to the very bottom of the file.
bhiv@devserver:~# sudo vi /etc/php/apache2/php.ini
bhiv@devserver:~# sudo vi /etc/php/cli/php.ini
bhiv@devserver:~# sudo apache2ctl restart
Hopefully there will be a php-pdo package soon. But until then, this was the simplest way to get PDO installed on your new Ubuntu system.

The intro paragraph sets this post up for an entirely different story.
Comment on June 8, 2006 @ 1:18 am
What did you think it would be about?
Comment on June 8, 2006 @ 2:35 am
I was about to try out how this worked, but apparently phpize didn’t install by default. I did a quick search for phpize in the dapper release at packages.ubuntu.com, but didn’t get any results. What package needs to be installed for phpize?
Comment on June 8, 2006 @ 8:26 pm
Justin,
php5-dev provides phpize.
you might also need the mysql packages:
libmysqlclient15-dev
libmysqlclient15off
Comment on June 9, 2006 @ 3:01 am
Cheers, worked a treat and saved me a bit of time. The best way to get phpize is to use the php5-dev package. Also I think sudo is needed on phpize in this case.
Comment on June 13, 2006 @ 6:36 pm
one additional package to install was “make” everything else looks to have worked just as documented above. Thanks.
Comment on June 13, 2006 @ 7:57 pm
Cheers mate, I had the same problem.
Hope a package is available soon!
Comment on July 10, 2006 @ 11:09 pm
when i do ./configure
error:
./configure: line 4144: syntax error near unexpected token `
Comment on July 14, 2006 @ 3:00 pm
Swegn,
Very strange. that line doesn’t have anything on it in my version. Make sure you are modifing PDO_MYSQL 1.0.2’s configure sript.
Comment on July 19, 2006 @ 12:42 am
Thanks a lot Brent! Works as described.
Cheers,
Mark
Comment on August 10, 2006 @ 2:59 pm
See: http://pecl.php.net/bugs/bug.php?id=6117
Simple answer without going manual:
PHP_PDO_SHARED=1 pecl install PDO_MYSQL
Comment on August 20, 2006 @ 11:34 pm
[...] The Solution - Installing PDO and PDO MySQL in Ubuntu (with the help from Brent) $sudo apt-get install php5-dev $sudo apt-get install php-pear $sudo apt-get install libmysqlclient15-dev [...]
Pingback on October 13, 2006 @ 2:04 pm
Same trick worked for PDO_SQLite . I think pecl on ubuntu dapper have some sort of problem.
Comment on December 14, 2006 @ 9:07 pm
that was very useful, thanks
Comment on January 12, 2007 @ 5:53 pm
I was getting the error that mysql header files couldn’t be found.
I installed the mysql-server and dev packages for mysql and it worked just fine.
# apt-get install mysql-server
# apt-get install libmysqlclient14-dev
Hope this might be helpful for other too…
Adios,
Me
Comment on February 1, 2007 @ 4:14 pm
Surely there has to be a package somewhere for pdo ? I am not a ubuntu user but forced to use it at work and ubuntu being the number one distro around, I was hoping the end user should not go through compiling and installing stuff.
Its not that I don’t know how to compile stuff its just I did everything I “had to do” and it was failing with “You’ve configured extension pdo_mysql, which depends on extension pdo,
but you’ve either not enabled pdo, or have disabled it.”
I was actually trying to set it up on my colleagues box and it was a bit embarrassing when things don’t work.
Thanks for pointing out the lines to comment off but I still hope to find a repository which holds the package as it helps in automating stuff when you are “mass installing” applications on your servers.
cheers,
Jeffery
Comment on February 2, 2007 @ 4:42 am
after pecl install pdo
i get message:
root@Luger:/etc/php5# pecl install pdo
downloading PDO-1.0.3.tgz …
Starting to download PDO-1.0.3.tgz (52,613 bytes)
………….done: 52,613 bytes
12 source files, building
running: phpize
sh: phpize: command not found
ERROR: `phpize’ failed
can anyone help me???
Comment on April 18, 2007 @ 1:25 am
Bob,
the php5-dev package provides phpize (or phpize5)
Comment on April 18, 2007 @ 10:44 am
Thanks a lot. You saved my ass lol
Comment on June 21, 2007 @ 12:56 pm
I have recently wrote a article on my website regarding how to setup a php dev machine using ubuntu 7.04,
You can view this here http://www.theatons.com/blog/2007/07/01/ubuntu-install-php5-mysql-apache2-ssl-pdo-pdo_mysql/
I hope this helps other ubuntu’ers.
Comment on August 14, 2007 @ 1:42 pm
[...] but at last I did it. I googled it and found someone has done this before on 6.06 the good howto is here. The author was able to pecl install pdo then downloaded from source and compiled in the server the [...]
Pingback on November 15, 2007 @ 9:16 pm
[...] but at last I did it. I googled it and found someone has done this before on 6.06 the good howto is here. The author was able to pecl install pdo then downloaded from source and compiled in the server the [...]
Pingback on January 4, 2008 @ 8:58 pm