How do I install a new PDO driver to an existing LAMP installation?

I am using Amazon Linux (on AWS EC2), and have installed PHP 5.5 and MySql from the Amazon repositories. When I look at phpinfo I can see that PDO is successfully installed, along with PDO_SqlLite. I need to add PDO_MySql.

Based on what I have read, I can either re-compile PHP with the PDO_MySql included, or download it from a repository. The first option sounds like hard work, and potentially very messy. The second option would be good, but as far as I can see the Amazon Linux yum repositories don't include the PDO_MySql driver for PHP 5.5. (I could be wrong, since I'm new to yum).

What other options are there? What would happen if I just downloaded the .so file from somewhere, put it alongside the other .so files, and called it in my php.ini?

I am using AMI 2013.09.

UPDATE: This pecl link, http://pecl.php.net/package/PDO_MYSQL, says that PDO_MySql has been moved to PHP source. Perhaps it's just a matter of enabling it then?

1 Answer 1


I haven't used EC2, but I'd be amazed if it didn't include php-mysql, which is a basic LAMP component. Does sudo yum install php-mysql work for you?

If not, you're missing some important repositories in yum, and your best choice would be to add them. I don't know much about that but I'm sure someone else here can help.

Yes, you can just copy in the files from another host, as long as it has the same architecture as yours (run arch to check), and is linked against library versions that exist on your host, which is probably true. Here are the files you'll need:

$ rpm -q php-mysql -l

But generally you're going to be much better off using your host's package manager to install those files and keep them up to date for you. I don't think that php-mysql has any installation scripts, but many other packages do and if you just copy the files in those scripts won't get run.

pdo_mysql is part of the PHP source, but distros break it out into a separate package from the main PHP packages.

  • Thanks Andrew, I went back to Ubuntu, so can't test out your answer. Seems like you know what you are on about though, so will mark it correct!
    – DatsunBing
    Jan 13, 2014 at 22:45
  • OK. In Ubuntu, sudo apt-get install php5-mysql. Jan 14, 2014 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.