Enabling MySQLi in PHP 7 on Ubuntu 14.04
When you install PHP 7 via the official Ubuntu repositories, the default SAPI (Server Application Programming Interface) package typically includes a curated subset of extensions to keep the base installation lean. This is standard practice for Debian-based systems, but it often leaves developers stranded when specific tools like phpMyAdmin fail because they rely on the MySQLi extension being present at runtime.
If your phpinfo() page does not list the mysqli module, or if you encounter errors stating "The mysqli extension is missing," the issue is almost certainly that the package was never installed. Unlike some modern distributions where extensions are bundled by default, older versions of Ubuntu and PHP 7 (specifically version 7.0) require an explicit installation step.
Installing the Missing Package
The first and most critical step is to install the specific package containing the extension. Based on the output from apt-cache search provided in your environment, the relevant package is php7.0-mysql.
You can resolve this immediately by running the following command in your terminal:
sudo apt-get update
sudo apt-get install php7.0-mysql
Once the installation completes, you must verify that the extension is actually loaded. The most reliable way to do this is to create a temporary PHP file or run the built-in server with a simple check:
<?php
if (extension_loaded('mysqli')) {
echo "MySQLi extension is loaded.";
} else {
echo "MySQLi extension is NOT loaded.";
}
?>
If this script outputs "MySQLi extension is loaded," your configuration issue is resolved, and tools like phpMyAdmin should now function correctly.
Understanding the Configuration
In many Linux distributions, installing a PHP extension package automatically adds an entry to php.ini. However, it is important to understand how the configuration file works in this specific context. The apt-get install command for php7.0-mysql usually appends lines like extension=mysqli.so to the main php.ini or creates a separate .ini file in the /etc/php/7.0/mods-available/ directory.
If you are running PHP as an Apache module, ensure that the line is uncommented in your main configuration file, typically located at /etc/php/7.0/apache2/php.ini. If you are using PHP-FPM or CLI, check the respective configuration directories (apache2, fpm, and cli). The path to the actual .so file is usually derived from the package installation logic, so manual copying of shared objects is rarely necessary unless you are compiling from source.
Potential Pitfalls and Architecture Mismatches
While installing php7.0-mysql solves 95% of these cases, there is a specific architectural nuance you must consider regarding your MySQL version. You mentioned running MySQL 5.5.47 alongside PHP 7.
The mysqli extension in PHP 7 was designed with the expectation that it would communicate with MySQL versions 5.6 and later. While the driver itself will install and load successfully on older servers like 5.5, there are subtle behavioral differences. The underlying protocol changes between MySQL 5.5 and 5.6 can sometimes cause issues if the PHP extension attempts to use features not available in the older database server.
If you proceed with this setup, be aware that while basic CRUD operations (Create, Read, Update, Delete) will work fine, advanced features like prepared statements with certain placeholders or specific result set handling might behave differently than expected on a 5.5 backend. This is a known limitation of using PHP 7's mysqli driver against legacy MySQL 5.5 instances.
For production environments where stability and feature parity are paramount, it is generally recommended to upgrade the database server to at least MySQL 5.6 or preferably 5.7 before relying on the full capabilities of the PHP 7 extension. However, if you are constrained to Ubuntu 14.04 and MySQL 5.5 due to legacy constraints, installing the extension as described above is the correct procedural fix for enabling phpMyAdmin.
Why This Approach Works
The reason this solution works without manual configuration of php.ini files or copying .so files is that the Ubuntu package management system handles the dependency resolution and file placement automatically. The php7.0-mysql package knows exactly where to drop the mysqli.so file and which virtual host configuration (Apache, FPM, CLI) it needs to target based on the architecture of your specific PHP SAPI installation.
By trusting the package manager's definition files, you ensure that the extension is linked against the correct version of the PHP library for your specific build. This avoids the common mistake of trying to manually link a generic libmysqlclient.so which might have version conflicts with the PHP 7 internal libraries.
