The mysqli extension is missing. Please check your PHP configuration
When you encounter the error message "The mysqli extension is missing," it usually indicates a disconnect between your compiled PHP binary and the actual shared object file, rather than a simple configuration oversight. In environments running Apache 2.2 with PHP 5, as described in common troubleshooting reports, the issue often stems from how the web server loads modules versus how PHP interprets its own extension directories.
Uncommenting extension=mysqli.so in your php.ini file is only half the battle. You must ensure that the path specified by the extension_dir directive actually points to the directory containing the compiled .so files. If you installed PHP via a package manager like apt-get or yum, the extension often resides in /usr/lib/php5/20090626/ (for older PHP 5.x) or /usr/lib/php/. Mismatched paths here are the most frequent culprit. Run php -i | grep "extension_dir" to verify the current setting. If this value points to a non-existent location, you must either create a symbolic link from the actual extension location to the expected directory or update the configuration file manually.
Another critical distinction exists between Apache's native module loading and PHP's internal extension loading. With PHP 5.2 and earlier, developers frequently used LoadModule directives in the Apache configuration to load extensions directly into the web server process. However, for mysqli, relying on extension=... in php.ini is generally preferred because it allows for easier switching between MySQLi and PDO-Mysql without recompiling Apache. If you are mixing LoadModule php5_mysqli_module directives in your Apache config with an entry in php.ini, you risk double-loading or conflicting symbol tables, which can silently break the extension even if phpinfo() does not explicitly list it.
A frequent pitfall involves PHP-FPM versus Apache setups. If you are using a reverse proxy or FastCGI process manager, the php.ini file loaded by Apache might be different from the one used by your backend process. Checking /proc/self/exe in a CLI context often reveals which binary is active; ensure that the extension files exist for that specific binary architecture (32-bit vs 64-bit). Mixing binaries of different architectures is a common source of "missing extension" errors that persist despite correct php.ini syntax.
To definitively diagnose why mysqli does not appear in your phpinfo() output, inspect the error log located at /var/log/apache2/error.log or /var/log/php_errors.log. Look for messages like "Unable load dynamic library 'mysqli'..." which explicitly state whether the file was found but failed to load due to a symbol mismatch. In some cases, loading mysql.so (the legacy extension) might conflict with mysqli.so if both are present and attempting to load simultaneously, though modern PHP versions handle this better than older 5.x builds.
If you are building custom PHP applications or working within the Laravel ecosystem, ensuring that your environment variables point to the correct PHP binary is essential. While some hosting environments abstract these details, self-hosted setups require strict alignment between the Apache module loader and the PHP CLI tool. For instance, if you install a new package providing libphp5, the extension might be placed in /usr/lib/php5/20090626/mysqli.so. If your php.ini still points to /usr/lib/php/extensions/no-debug-non-zts-..., the load will fail.
In scenarios where you cannot modify the global php.ini, consider using an Apache .userdir configuration or a specific virtual host setup that loads a tailored php.ini. However, be cautious of version-specific behaviors; PHP 5.2 through 5.6 had distinct extension loading mechanisms compared to later versions. Always verify the exact PHP version string (php -v) before assuming directory structures based on older documentation.
Ultimately, resolving this issue requires a methodical check of the file system paths, the Apache module loader settings, and the specific binary architecture. Once the extension_dir is corrected and conflicting modules are removed, reloading Apache with service apache2 restart should bring the mysqli extension back into your phpinfo() output, restoring database connectivity for your applications.
