PHP Fatal error: Class 'PDO' not found
When you encounter PHP Fatal error: Class 'PDO' not found, your immediate instinct might be to check if the PDO extension is loaded. In many cases, the core issue isn't that the extension is missing from the installation, but rather a mismatch between what your web server expects and what PHP actually sees at runtime.
Looking at the specifics of this failure, the error originates in Cake/Model/Datasource/Database/Mysql.php. This indicates you are running a legacy CakePHP application (likely version 1.x or early 2.x) on a shared hosting environment like cPanel with CloudLinux on CentOS 6. The stack trace points to line 177, where the code attempts to instantiate or reference the PDO class.
Your PHP INFO output confirms that PDO support is enabled and that the pdo_mysql driver is also active. You can see the Client API version at 5.5.24, which aligns with the era of CentOS 6. However, your PHP INI file explicitly lists extension=pdo.so, extension=pdo_sqlite.so, and crucially, extension=pdo_mysql.so. This suggests the module is compiled in or loaded via the .so directive.
So, why does the fatal error persist despite the extension appearing enabled?
The most common culprit in shared hosting environments is PHP opcode caching. Tools like OPcache or APC often have their own configuration files that sit alongside your main php.ini. If the opcode cache is configured to ignore specific extensions or if there was a recent deployment where an older binary was swapped out without updating the cache settings, the interpreter might report that PDO is enabled while the actual code path fails to load it.
Another frequent scenario involves multiple PHP versions. On CentOS 6 with CloudLinux, you often have access to multiple PHP versions (e.g., 5.3.15, 5.4, 5.5). The error log shows PHP 5.3.15. If your application relies on features introduced in later versions or if the specific pdo_mysql extension is built against a different library version than what the system expects, you can hit this wall. Specifically, ensure that the extension=pdo_mysql.so line is not commented out in every active configuration file, including those inside the cPanel home directory or the application-specific virtual host config.
Sometimes the issue lies in how the extension is loaded relative to other dependencies. The INI snippet shows pdo_sqlite.so and sqlite.so. While these are valid, loading SQLite extensions alongside MySQL can occasionally cause conflicts in older PHP builds if not handled correctly by the underlying C library versions. However, the primary suspect remains the MySQL driver itself.
To resolve this on a cPanel server, you should first verify the exact PHP version your application is using via the .htaccess file or the Select PHP Version tool in the cPanel interface. Ensure that the selected version matches the one where PDO is confirmed to be loaded. If you have access to the root configuration, try uncommenting the line:
extension=pdo_mysql.so
If you are on a system using OPcache, check if the opcache.enable directive is causing issues by temporarily disabling it in your php.ini to see if the error vanishes. This helps isolate whether the issue is a caching corruption or a genuine extension loading failure.
For CakePHP applications specifically, legacy versions were sometimes sensitive to the order of extension loading. If you cannot modify the main php.ini, ensure that the specific PHP-FPM pool configuration associated with your domain explicitly loads the PDO extensions without relying on global defaults.
If all configuration changes fail, and the error persists despite the INI file showing the extension is loaded, consider rebuilding the PHP package or contacting your hosting provider to verify that the shared library libmysqlclient.so matches the version expected by the installed pdo_mysql.so. A mismatch here can cause the module to load but fail silently until a specific class instantiation triggers the fatal error.
