How to fix Fatal error: Class ‘PDO’ not found in PHP apps like Drupal, Prestashop, Joomla, etc

How to fix Fatal error: Class ‘PDO’ not found in PHP apps like Drupal, Prestashop, Joomla, etc

Fatal error: Class ‘PDO’ not found is an error seen in websites running PHP applications such as Drupal, Prestashop, WordPress, etc. It’ll look something like this:

Fatal error: Class 'PDO' not found in /home/romrac/public_html/drupal/includes/database/ on line 187

This error reports that the web server was unable to locate a PHP module called “PDO” in the server. Web applications require this PHP module to establish a database connection.

At Bobcares’ web server management services, this error is most commonly reported by website owners who use a VPS or a dedicated server to host their site. Server misconfiguration is the common cause of this error, and is mostly seen on newly setup servers.

PHP/MySQL errors in your site?



For instance, in a support request we received recently, the website was recently migrated to a new VPS. The website used Drupal, and the website owner had personally confirmed that all required modules were installed in the VPS.

To troubleshoot, we took a look at the PHP configuration using the phpinfo function. It showed the below output:

Incorrect extension_dir causing Fatal error: Class 'PDO' not found

Incorrect extension_dir causing Fatal error: Class ‘PDO’ not found

As you can see, the modules extension directory is mentioned as “/usr/local/lib/php/extensions/no-debug-non-zts-20130716“, whereas the extension directory for this server was “/usr/lib/php5/20121212“. So, PHP was looking for the PDO extension in the wrong directory. This happened because:

  • The website was using a custom PHP configuration loaded from “/home/romrac/conf/php.ini” instead of the system default “/etc/php5/apache2/php.ini“.
  • The custom PHP configuration was created to match the old server configuration. In the old server had the PHP extensions stored at /usr/local/lib/php/extensions/no-debug-non-zts-20130716. The location was not updated to match the new VPS settings.

To fix this, we could either change the “extension_dir” variable in “/home/romrac/conf/php.ini” to “/usr/local/lib/php/extensions/no-debug-non-zts-20130716“, or we could just disable a custom PHP configuration file. Since this customer used this VPS for just one website, we disabled a custom PHP configuration by removing the entry “PHPINIDir /home/romrac/conf/” from the Apache configuration file.

PHP and MySQL errors giving your websites a hard time?

Don't let the intermittent website errors affect your business. We're here to help you.



  1. I had a difficulty with this too.
    On Windows, the addition needs to be
    (or extension=pdo_mssql.dll is using MSSQL)
    I was querying if adding this to the install file would be a good idea or not?

    • Hi Jessica,

      Thanks for your comment.

      I’m not sure which install file you’re referring to here.

      We do use custom installation scripts for mass deployments that takes care of all these settings, however I don’t think that is the one you have in mind.

      Which install file are you thinking of?


Submit a Comment

Your email address will not be published. Required fields are marked *

Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.