Where are php's extensions .so files located?

Where are php's extensions .so files located?

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

Stefan Bogdanescu

Founder & Senior Architect

Where are PHP's extensions .so files located?

When you inspect configuration files like mysqli.ini, mysql.ini, or pdo_mysql.ini, you will encounter lines such as extension=mysqli.so. This directive tells the PHP interpreter to load a specific shared object file at runtime. While the configuration file explicitly names the library, it rarely specifies the absolute path where that file resides on your filesystem. Determining the actual location of these .so files is critical for troubleshooting "Extension not loaded" errors, debugging segmentation faults, or managing dependencies in complex environments.

The location of PHP extensions depends heavily on how PHP was compiled and whether you are running a development build or a production package distribution. In a standard Linux environment using packages like php-mysql or php-pdo, the shared objects are typically stored in directories designated for dynamic libraries. On most modern distributions (Debian, Ubuntu, CentOS, RHEL), this is /usr/lib64/php/modules/ for 64-bit systems or /usr/lib/php/modules/ for 32-bit systems. You can verify this by listing the contents of that directory and looking for files matching the names in your php.ini, such as mysqli.so.

If you are building PHP from source, the directory structure changes based on your compile-time configuration. When running the ./configure script, you likely specified a prefix (e.g., --prefix=/usr/local). In these scenarios, the extensions usually reside in a subdirectory within your installation path, often /usr/local/lib/php/extensions/no-debug-non-zts-20240701/. The naming convention includes the build timestamp and debug flags. If you see a file named mysqli.so but your config expects mysqli.so, checking for a versioned directory like no-debug-non-zts-20231201 is often the solution to finding the correct binary.

It is also important to distinguish between the compiled extension and the original source code archive. The .so file you are looking for is the compiled binary, not the .tar.gz download you might have extracted from PECL. The PECL repository contains the C/C++ source code that must be compiled against your specific PHP version before it becomes a loadable module. If you downloaded pdo_mysql-0.13.x.tgz but cannot find the corresponding .so file, you are missing the compiled binary, which usually requires running phpize, compiling with make, and installing with make install.

On Windows systems or environments using the Thread Safe (TS) build of PHP, the extension files often have a different suffix, such as .dll instead of .so, and may be located in the ext directory alongside the core PHP files. If you are managing multiple PHP versions, such as with php-fpm-pool configurations or containerized environments (Docker), the location is defined within the Dockerfile's entrypoint scripts or build stages. You must ensure that the extension file path matches exactly what is declared in the extension= directive; a mismatch here is a common cause of startup failures.

For developers maintaining legacy applications or migrating from older PHP versions, understanding these paths helps in debugging why an extension fails to load. If the file exists but PHP cannot find it, check that the extension_dir setting in your php.ini points correctly to the directory containing the .so files. Misconfigured paths here can lead to silent failures where the extension is skipped entirely, causing features like prepared statements or specific database drivers to break without immediate error messages.

For those integrating PHP into modern stacks, specifically when utilizing Laravel projects, ensuring that all required extensions are present and correctly located in the server environment is part of standard deployment hygiene. While detailed configuration guides for this can be found on resources like https://laravelcompany.com, understanding the underlying filesystem paths remains essential for resolving low-level issues that high-level documentation cannot address.

Our network