Installing PDO_MYSQL on CentOS (the easy way)

 Jul, 24 - 2008   10 comments   How To

When deploying LAMP projects, quite often we find ourselves being given access to a newly installed server with distribution-specific default configurations, which are usually very stripped down. Our Carbon Content Management Toolkit, which runs on top of the Zend Framework, uses the PDO_MYSQL driver for data access, along with a few other modules that are typically present in commercial hosting environments, but not always included in an OS’s default PHP build.

Getting PEAR, PECL, and a build environment set up can be a time consuming process if you do it from scratch. Luckily most OSs these days come with easy to use package management systems that take care of downloading, building, and installing the packages you need, and their dependancies.

Check the package management system entry on Wikipedia if you’re unsure about which package system your OS uses. Each one works a little bit differently, but the concepts are the same. You’re going to need to set up your OS’s version of the following packages in order to make your life easy:

php-devel
php-pear
mysql-devel
httpd-devel

The package names will differ a bit for each system. The following example uses the Yum package manager in CentOS, and gets PDO_MYSQL up and running in just a few minutes.

# yum install php-devel php-pear mysql-devel httpd-devel
# pecl install pdo
# PHP_PDO_SHARED=1 pecl install pdo_mysql

Add these lines to php.ini:

extension=pdo.so
extension=pdo_mysql.so

Now restart Apache, and you should see your PDO modules in phpinfo(), Robert’s your father’s brother.
# apachectl restart

If you need to actually make a custom PHP build, you should have everything you need to do that after installing the devel packages. You still may need to build any dependancies that your custom PHP build requires, but your package system should make that fairly easy.


Related articles

 Comments 10 comments

  • Kramer auto Pingback[…] eCommerce cart and it’s requiring PDO_MYSQL to be installed, so I followed the directions of this site which shows how to do it using pecl, and followed it to the letter, but now whenever I include […]

  • […] на оригинал статьи по установке pdo_mysql на […]

  • Kramer auto Pingback[…] You've been Stumbled! […]

  • Preci says:

    Thanks a lot.
    Your tip was very important for me.

    ReplyReply
  • franks says:

    Thank you very much. This helped me.
    I did’n need to put in the extensions into my php.ini, it was precopiled with it.
     
    best regards,
     
    franks

    ReplyReply
  • Constantine says:

    Rob,
    You save my day. I was about to recompile whole php because the pdo_mysql was disable in CentOS5 by default on Godaddy VPS server and magento commerce need this library. Than I found your post and it worked for me .. Thank you,
     
    Constantine
    http://www.webika.com

    ReplyReply

  • Leave a Reply

    Your email address will not be published. Fields with * are mandatory.