Fatal error: Class 'PDO' not found
When working with Content Management Systems such as Drupal or other programs in your hosting account, you may run across certain errors during either the initial setup or even after a php or Apache upgrade on your server. One common error you may run across when trying to enter your site is the PDO error. It looks like the one below.
Check the php modules list to see if it is enabled
The first thing we should check is to see if the server has the PDO extensions enabled.
- Log into your server via SSH.
- Run the command below.
Ensure they are being called in the php.ini file
If the PDO is displayed in the list of currently installed php modules, you will want to check the php.ini file in the relevant folder to ensure they are being called. Somewhere in the php.ini file you should see the following:
Ensure the php.ini file is recursive
You will next want to ensure that the php.ini file is being used by all the folders and files underneath the main folder. This is known as being recursive. Below is a link to our article on doing just that.
How can I make my php.ini file recursive ?
Check the extension directory for php
It is also possible that the php.ini file is looking into an incorrect extension directory, especially if you just performed an update. Below are the instructions for adjusting the extensions directory in the php.ini file:
- Log into your account via SSH.
- Navigate to the /usr/local/lib/php/extensions directory.
- Run the ls -lah command on the directory so you can see all the exension directories inside.
- Check the dates to find the most recent one. Notate the full name of that directory. In our example it is no-debug-non-zts-20100525.
- Now you will need to open your php.ini file. Navigate to the home directory and open the file using nano.
- Once the file is opened find the extension_dir setting and ensure that the path is the same as the latest one in your /usr/local/lib/php/extensions directory.
; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20100525"
drwxr-xr-x 15 root root 4.0K Aug 28 2012 ../
drwxr-xr-x 2 root root 4.0K Sep 2 2010 no-debug-non-zts-20060613/
drwxr-xr-x 2 root root 4.0K May 10 11:48 no-debug-non-zts-20090626/
drwxr-xr-x 2 root root 4.0K Oct 10 10:56 no-debug-non-zts-20100525/
Comment out the extension_dir in php.ini
One additional option to the above fix is to simply comment the line for the extension_dir setting out in the php.ini. Doing this does no harm as it simply makes the php use the extension directory from the main server php.ini, which is most probably the one you want. To do so, simply place a semicolon (;) at the very beginning of the line as demonstrated below.
;extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20100525"
Support Center Login
Social Media Login
2014-11-09 3:02 pm
I just moved over to VPS1000 hosting from shared hosting. I called tech support, and they moved my php.ini file to the public_html directory. Then I added the extension lines as noted above, but it still didn't work. However, once I commented out the extension_dir line as noted in the last step, it worked!!!! Thanks for the help! --Rob P.
2015-11-18 7:45 am
That was awesome.. You really helped me a lot :-)