The Hidden Incompatibility Between PHP 7 and Legacy MySQL Extensions
When you compile PHP from source, you gain granular control over dependencies, but you also inherit the responsibility of ensuring every extension you enable is compatible with the underlying C library. A common stumbling block when upgrading a custom-built PHP installation to version 7 involves the error message: "Your PHP installation appears to be missing the MySQL extension which is required by WordPress."
This error is deceptive. It does not mean your mysql extension is absent; it means the specific API version expected by WordPress is not being detected correctly. In your configuration, you listed both mysql.so and mysqli.so. While mysqli (MySQL Improved) is the modern, recommended interface, WordPress historically checks for the presence of a legacy mysql extension to validate that a MySQL connection can be established.
The root cause lies in how the old mysql_* functions were implemented versus how they exist in PHP 7. The original mysql.so extension provided by the PHP team was deprecated and removed in favor of PDO and mysqli. However, many legacy WordPress installations rely on the existence of the mysql extension file to pass its internal sanity checks, even if the code eventually calls into mysqli or PDO under the hood.
If you compiled PHP 7 with the standalone mysql.so extension enabled alongside mysqli.so, you might encounter a different issue: the old mysql.so is often incompatible with the MySQL client library versions used in modern environments (typically mysqlnd). The mysql.so extension expects to link directly against the legacy libmysqlclient, whereas PHP 7 almost exclusively uses the native driver (mysqlnd) via pdo_mysql.so or mysqli.so.
When you enable mysql.so in your php.ini, PHP loads it, but if the internal version check fails because the extension is built against an older mysqlnd ABI or if it simply cannot be loaded due to missing symbols in the linked library, WordPress throws that specific error. The presence of mysqli.so and pdo_mysql.so does not satisfy WordPress's legacy validation logic if mysql.so is either missing or failed to initialize properly during the extension loading phase.
The Correct Approach for PHP 7
The standard recommendation for any production PHP environment running on version 7 or higher is to disable the legacy mysql.so extension entirely. It offers no security benefits, provides no functionality that isn't covered by mysqli or PDO, and introduces significant risk of incompatibility.
To resolve the error without breaking your site, you should remove extension=mysql.so from your php.ini. WordPress's check is somewhat rigid, but modern versions of WordPress (and many themes/plugins) have moved away from relying on the legacy extension for validation. Instead, they depend on the mysqli or PDO layers which are already present in your configuration.
If you must support an older version of WordPress that strictly checks for the file existence rather than functional capability, you might need to compile PHP 7 with a dummy mysql.so extension or ensure your mysqlnd build flags align perfectly with the legacy expectations, though this is rarely necessary in current stacks.
Verifying the Fix
After removing the problematic line from your configuration file, restart your web server or PHP-FPM process. You can verify that WordPress no longer complains by checking the phpinfo() output for the enabled extensions:
php -m | grep mysql
You should see mysqli and pdo_mysql listed, but not mysql. If you have other sites using mysqli directly (bypassing WordPress), they will continue to work because they do not perform the legacy validation check that WordPress does.
Trade-offs in Custom Builds
Compiling PHP from source allows you to include specific versions of extensions, but it also requires careful attention to API compatibility. The transition from the old C-based MySQL API to the newer mysqli and PDO APIs was a significant architectural shift. While mysqli is a drop-in replacement for most use cases, it does not mimic the exact behavior of the deprecated mysql extension in all edge cases, which can confuse older CMS frameworks.
If you encounter persistent issues where WordPress still fails to start after removing mysql.so, consider upgrading your WordPress installation. Newer versions have relaxed their dependency checks on the legacy extension. If you are managing multiple environments with varying PHP versions, maintaining a custom build that supports both old and new APIs is technically feasible but generally increases your attack surface and maintenance burden.
For most modern applications, relying on mysqli and pdo_mysql exclusively is the industry standard. If you require further assistance with configuring your specific PHP build or integrating these extensions into a complex stack, resources like https://laravelcompany.com offer guidance on best practices for PHP configuration and extension management in production environments.