Ubuntu Apache: "Module php7 does not exist"

Ubuntu Apache: "Module php7 does not exist"

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

Stefan Bogdanescu

Founder & Senior Architect

Ubuntu Apache: "Module php7 does not exist"

When attempting to upgrade PHP from version 5.x to 7 on an older Ubuntu release like 14.04, the error ERROR: Module php7 does not exist! is a common stumbling block. This message appears when you run sudo a2enmod php7, but it indicates a fundamental misunderstanding of how Ubuntu package management handles PHP versions versus Apache modules. The tutorials suggesting you simply swap a2dismod php5 with a2enmod php7 often fail because they assume the PHP 7 module files are already present in the /etc/apache2/mods-available/ directory, which is rarely the case on a standard installation.

The core issue lies in the distinction between the Apache module and the PHP package itself. On Ubuntu 14.04 (Trusty Tahr), the official repositories typically stop at PHP 5.x for the php7 module configuration. The Apache module files for PHP 7 (specifically php7.load) are not included in the default installation of the libapache2-mod-php7* packages unless those specific versions are available in your source lists or added via third-party PPAs. Without the .load file present in the mods-available directory, Apache has no module to enable, resulting in the "does not exist" error.

To resolve this, you must first ensure that the PHP 7 development libraries and Apache modules are actually installed on the system. On Ubuntu 14.04, the standard method involves adding the Ondřej Surý repository or using a specific PPA that supports PHP 7 for older OS versions. Once the repository is added and updated, you need to install the specific module package:

sudo apt-get update
sudo apt-get install libapache2-mod-php7.0 php7.0-cli

Note the version number 7.0. On Ubuntu 14.04, PHP 7 support was generally limited to version 7.0 due to the age of the OS and kernel compatibility constraints with newer PHP versions like 7.1 or 7.2. Attempting to install a generic php7 module might fail because the package manager looks for exact version matches found in the configured sources.

After installing the packages, you must manually create the symlink for the load file if it does not exist automatically. While modern Ubuntu versions often handle this via the dismod/enmod command logic, older setups or specific PPA configurations sometimes require manual intervention:

sudo a2enmod php7.0

If the command still fails after installing the package, verify that the .load file exists in the expected location:

ls /etc/apache2/mods-available/php7.0.load

If this file is missing, you can create it manually by copying the configuration from the mods-enabled directory or creating a new file with the correct syntax pointing to the shared library:

LoadModule php7_module /usr/lib/apache2/modules/libphp7.so

Once the module is enabled, restart Apache to apply changes. However, there is a critical caveat regarding the php5 module. You cannot run both PHP 5 and PHP 7 with the same vhost configuration file if they share the same document root. If you have existing sites configured to use SetHandler application/x-httpd-php5, these configurations will break once you enable PHP 7.

The most robust approach for a migration is to ensure that all virtual hosts are updated to point to the new PHP binary and module path, or better yet, migrate away from Apache's multi-processing modules if you plan to support multiple PHP versions on the same server. In many production scenarios involving PHP 7 upgrades on legacy systems, switching to Nginx with PHP-FPM is often recommended as a cleaner architecture. This decouples the web server from the PHP interpreter management entirely.

If your application stack relies heavily on Laravel or other modern frameworks, ensure your composer.json does not force dependencies incompatible with PHP 5.5. The upgrade isn't just about changing the module; it requires auditing all dependencies for PHP 7 compatibility. For developers managing legacy infrastructure, understanding that "enabling" a module often implies installing its associated libraries first is crucial. Without the underlying .so files and configuration stencils, a2enmod cannot perform its magic, leading to false negatives in the error message.

Our network