PHP 8.0: Apache Handler: Module name and file path changes

Version8.0
TypeChange

The Apache 2 Handler SAPI in PHP 8.0 is renamed, and can affect when PHP is used as an Apache module.

It is recommended to use PHP-FPM with Apache mod_event MPM. However, PHP 8.0 still supports the Apache 2 Handler SAPI, which is integrated with Apache 2 web server as an Apache module.

Module identifier renamed to php_module

In PHP 8.0, the Apache module identifier is renamed to php_module.

In PHP 7.x versions, it was named php7_module, and in PHP 5.x, it was named php5_module.

This means that all references to the Apache module loading configuration needs to be updated:

- LoadModule php7_module "/usr/lib/apache2/modules/libphp7.4.so"
+ LoadModule php_module "/usr/lib/apache2/modules/libphp8.0.so"

Apache will throw an error similar to the one below if the module name php8_module is used:

Can't locate API module structure `php8_module` in file ...

A full guide on installing and upgrading PHP 8.0 on Ubuntu

Apache <IfModule> directives, and any other places the module name is used must be updated to their new name as well:

- <IfModule php7_module>
+ <IfModule php_module>
    DirectoryIndex index.html default.php index.php
    AddHandler application/x-httpd-php .php
</IfModule>

Windows DLL file name changes

On Windows, the DLL file name is updated for PHP 8. Module identifier is php_module.

- LoadModule php7_module "W:/php/php-8.0.0-Win32-vc15-x64/php7apache2_4.dll"
+ LoadModule php_module "W:/php/php-8.0.0-Win32-vc15-x64/php8apache2_4.dll"

It might be necessary to manually update development environment bundles such as XAMPP, Wamp, or Laragon to reflect this.

Backwards Compatibility Impact

Due to the module identifier renaming, errors similar to Can't locate API module structure php8_module in file might occur, but most distributions, software collections, and PPAs automatically configure the Apache2Handler on behalf of the user, so the chances of end users running into this issue is uncommon.


Implementation