Installing PDO for PHP5 on Ubuntu

For some reason there aren’t any PDO packages for PHP 5 on Ubuntu 6.10. They’re pretty easy to install from PECL but you might need to install the dev version of your database client libraries. Below is what I had to type to install PDO with the MySQL driver.

% sudo apt-get install libmysqlclient15-dev
% sudo pecl install pdo
% sudo pecl install pdo_mysql

You then need add the following to the end of your php.ini file(s). Depending on which version of PHP you installed they’ll be /etc/php5/apache2/php.ini, /etc/php5/cgi/php.ini and /etc/php/cli/php.ini.

extension=pdo.so
extension=pdo_mysql.so

Update: Before you can install any PECL extensions you need to install the php5-dev package. For information see my post about Using PECL with Ubuntu.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Slashdot
  • Facebook
  • TwitThis
  • Google
  • Live
  • YahooMyWeb
  • del.icio.us
  • StumbleUpon
  • Technorati

6 Comments so far »

  1. Meint said,

    Wrote on March 9, 2007 @ 4:59 am

    I’m getting “ERROR: `phpize’ failed” with
    “sudo pecl install pdo” and
    “sudo pecl install pdo_mysql”

    This is my full log:

    mspan@baksteen:~$ sudo 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
    mspan@baksteen:~$ sudo pecl install pdo_mysql
    downloading PDO_MYSQL-1.0.2.tgz ...
    Starting to download PDO_MYSQL-1.0.2.tgz (14,778 bytes)
    .....done: 14,778 bytes
    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
    7 source files, building
    running: phpize
    sh: phpize: command not found
    ERROR: `phpize' failed
    

    I use ubuntu 6.06 LTS with php 5.1.4 (and like it a lot!)

  2. Rich said,

    Wrote on March 9, 2007 @ 9:34 am

    @Meint Thanks for the response. You need to install the php5-dev package first. I’ve updated this post and written a new post about using PECL with Ubuntu/

  3. smiley said,

    Wrote on December 15, 2007 @ 10:40 am

    I hava a prob too. I want to use pgsql instead of mysql.How can I have php_pdo_pgsql.so that can i put in my php.ini, so i can run my project.pls help me to solve this prob.

    Tanx in advance,
    Smiley

  4. smiley said,

    Wrote on December 15, 2007 @ 5:45 pm

    how about in pgsql? I am using pgsql for my database. I had installed pdo using pecl, then I added extension=pdo.so in my php.ini.When I restart my apache and browse my localhost there is a
    Fatal error: Class ‘PDO’ not found in /var/www/repos/php_iTranscribe-admin/db.inc on line 21
    displayed in my browser.

    Anybody help me to solve this..

    Version of my ubuntu is 6.10
    php is 5.1.6
    apache 2

    Thank you in advance.

    cheers,
    Smiley

  5. EriChen 工作志 » Blog Archive » ubuntu 上装 php-pear said,

    Wrote on April 1, 2008 @ 4:38 pm

    [...] 源头 整个 Yo2 上的相关文章:M1710上装ubuntu(续) 在Ubuntu上装VMtools的痛苦经历 7 种流行 PHP IDE 的比较(转) T恤DIY 这几天不顺啊~ printYo2FavControl(“”,”",”ubuntu 上装 php-pear”,”前提 sudo apt-get install apache2 php5 php5-dev 等等 sudo apt-get install libmysqlclient15-dev sudo pecl install pdo sudo pecl install pdo_mysql 说明 phpize 是 php5-dev 中的一个程序,所以如果你看到 ERROR: `phpize’ failed 表示你没有安装 php5-dev 源头 整个 Yo2 上的相关文章:M1710上装ub”);最近阅读过此文章的网友: [...]

  6. Being Linux admin - setting up virtual servers and Samba | ProDevTips - dev notes and tutorials said,

    Wrote on March 10, 2009 @ 5:59 am

    [...] drivers on dapper drake with php 5.1.2 (as root/su), the guide has been ripped out of bhiv.com and http://www.buggy.id.au: apt-get install php5-dev apt-get install php5-pear apt-get install libmysqlclient15-dev pecl [...]

Comment RSS · TrackBack URI

Leave a Comment

You must be logged in to post a comment.