How to install new PDO driver to existing LAMP install

5,606

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
/etc/php.d/mysql.ini
/etc/php.d/mysqli.ini
/etc/php.d/pdo_mysql.ini
/usr/lib64/php/modules/mysql.so
/usr/lib64/php/modules/mysqli.so
/usr/lib64/php/modules/pdo_mysql.so

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.

Share:
5,606

Related videos on Youtube

DatsunBing
Author by

DatsunBing

Updated on September 18, 2022

Comments

  • DatsunBing
    DatsunBing almost 2 years

    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?

  • DatsunBing
    DatsunBing over 10 years
    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!
  • Andrew Schulman
    Andrew Schulman over 10 years
    OK. In Ubuntu, sudo apt-get install php5-mysql.