How To enable extension PDO In ubuntu 14.04

Posted July 8, 2016 113.9k views

How to enable extension PDO in my ubuntu droplet

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

You can do this with:

sudo apt-get update
sudo apt-get install pdo-mysql php5-mysql

If after this you are unable to use the extension you can check your /etc/php5/apache2/php.ini and make sure it includes:
  • /etc/php5/apache2/php.ini

    in this path u mention, i dont have php5 folder. i have just php, in that php i have .git, 5.6, 7.0, 7.1, 7.2 folders like that.

    • after i did this.. “ sudo apt-get install php5-mysql”

      i got this…

      Reading package lists… Done
      Building dependency tree
      Reading state information… Done
      Package php5-mysql is not available, but is referred to by another package.
      This may mean that the package is missing, has been obsoleted, or
      is only available from another source

PHP should already have PDO extension enabled. What you probably need is the mysql driver for it.

# test if php5-mysql package is installed
dpkg-query --status php5-mysql | grep Status

# install the package if the above command indicates that it is not installed
sudo apt-get install php5-mysql

[Edit: oops, @ryanpq already answered]