Getting PDO to work with Ubuntu’s 6.06 LTS (Dapper Drake)

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:

to the files:


(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

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:
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.

25 thoughts on “Getting PDO to work with Ubuntu’s 6.06 LTS (Dapper Drake)

  1. The intro paragraph sets this post up for an entirely different story.

  2. 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, but didn’t get any results. What package needs to be installed for phpize?

  3. Justin,

    php5-dev provides phpize.

    you might also need the mysql packages:

  4. 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.

  5. one additional package to install was “make” everything else looks to have worked just as documented above. Thanks.

  6. when i do ./configure

    ./configure: line 4144: syntax error near unexpected token `

  7. 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.

  8. Pingback: PHP with PDO_MySQL and error “SQLSTATE[HY000]: General error: 2036″: fixed at Joel’s Corner

  9. 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…


  10. 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.


  11. 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???

  12. Pingback: Because I Learn » Blog Archive » Compile PDO drivers from source

  13. Pingback: Not So Wise

  14. Pingback: Being Linux admin - setting up virtual servers and Samba | ProDevTips - dev notes and tutorials

  15. Thx. This helped me a lot. Now I have PDO and don’t need to adjust my scripts.


  16. Pingback: A problem with instalation of pdo_mysql « e-notebook

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>