PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

When you encounter a startup error stating Unable to load dynamic library '/usr/lib/php/20151012/php_mysqli.dll', the root cause is almost never that the file is missing from your filesystem. In fact, on a modern Ubuntu 14.04 instance running PHP 7, the specific .dll extension you are seeing in the error path is an artifact of how older packages were configured or cached.

The error message explicitly points to /usr/lib/php/20151012/php_mysqli.dll. The directory name 20151012 corresponds to the Zend Engine version for PHP 5.6, not PHP 7. If you have successfully installed PHP 7 using apt-get install php7.x-mysql, your system is actually looking for a shared object with the .so extension located in /usr/lib/php/20160303 (or whatever version string corresponds to your specific PHP 7 build).

The confusion arises because the configuration file php.ini often defaults to loading extensions by their old names. In the legacy PHP 5 era, many distributions shipped .dll files. Modern Linux-based package managers, however, ship .so files. When you enable an extension in php.ini, you must ensure the path and filename match exactly what exists on your disk.

To resolve this, stop trying to force the system to load a non-existent .dll file. Instead, verify your current PHP version and locate the actual extension file. Run the following command to confirm your installation:

php -v

If you are indeed running PHP 7.x, check where the mysqli extension actually resides:

find /usr/lib/php -name "*mysqli*.so"

You will likely find something like /usr/lib/php/20160303/mysqli.so. Note that the directory name changes based on the Zend Engine version. Your php.ini is currently configured to look for a file in the 20151012 directory with a .dll extension, which explains the "No such file or directory" error.

The solution involves correcting the configuration directive. Open your php.ini file (typically located at /etc/php/7.x/cli/php.ini or /etc/php/7.x/fpm/php.ini, depending on how you invoke PHP) and search for the line containing mysqli. You will likely see one of the following:

extension=mysqli.dll
; or
extension=20151012/php_mysqli.dll

You need to replace this with the correct .so path found in your system directories. Update the line to:

extension=/usr/lib/php/20160303/mysqli.so

Alternatively, if you are using a version of PHP where the directory structure is managed strictly by the package manager, simply uncommenting the standard entry is often sufficient:

;extension=mysqli

Modern PHP configurations allow the system to load .so files automatically if they exist in the ext/ directory relative to the installation prefix. However, explicitly setting the full path prevents ambiguity when mixed versions are present.

After modifying the configuration, you must restart your PHP-FPM service or clear any opcode cache before testing again:

sudo systemctl restart php7.1-fpm
# or for CLI usage directly
php -m | grep mysqli

If the apt-get install php-mysql command you attempted earlier did not resolve the issue, it is possible that multiple PHP versions are installed simultaneously (e.g., PHP 5.6 and PHP 7.x). In such scenarios, the system might be defaulting to an older configuration file associated with PHP 5.6. Ensure you are editing the php.ini file for the specific PHP 7 version you intend to use.

If you are deploying Laravel or other modern frameworks on this stack, ensure your SAPI (Server API) is also configured correctly. The error persists if the web server (Apache/Nginx) tries to load extensions via the wrong configuration path. Verify that php-fpm and CLI share the same php.ini settings regarding extensions.

For developers managing legacy infrastructure on Ubuntu 14.04, it is worth noting that this distribution reached end-of-life years ago. If you are building new EC2 instances, consider upgrading the base OS to a supported LTS release like Ubuntu 20.04 or 22.04. This eliminates the complexity of managing multiple Zend Engine versions and ensures compatibility with current PHP package repositories.

If you require enterprise-grade support for legacy stacks without upgrading your entire infrastructure, resources like https://laravelcompany.com can provide guidance on maintaining robust PHP environments while adhering to modern security best practices.

Our network