Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Apache on Windows refuses to start because httpd.conf names a PHP module it cannot find

ErrorSyntax error on line 531 of C:/Apache24/conf/httpd.conf: Can't locate API module structure `php8_module' in file C:/php/php8apache2_4.dll

Short answer

LoadModule needs the name of the module variable inside the DLL. For PHP 8 that name is php_module, not php8_module and not php7_module. Fix that first, and make sure the DLL is php8apache2_4.dll from the Thread Safe PHP zip, written with forward slashes.

  • Applies to Apache 2.4, PHP 8.3 Thread Safe, Windows 11
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Let Apache test its own configuration. It names the line it chokes on. Then print the PHP lines of httpd.conf and look at the first word after LoadModule.

    C:\Apache24\bin\httpd.exe -t
    findstr /n /i "php" C:\Apache24\conf\httpd.conf
  2. 2Match what you see, then jump to its fix

    1. 1The error quotes php8_module (or php7_module) in backticks and the DLL path next to it is right.The LoadModule line uses a module name that PHP 8 does not haveFix
    2. 2php8apache2_4.dll is not in the PHP folder, and the module cannot be loaded at all.The PHP folder holds the Non Thread Safe build, which has no Apache moduleFix
    3. 3The path in the error is not the one where you unpacked PHP, or it holds single backslashes.Backslashes or a wrong folder in the pathFix

What does the error look like?

  • Syntax error on line 531 of C:/Apache24/conf/httpd.conf: Can't locate API module structure `php8_module' in file C:/php/php8apache2_4.dll
  • Apache service will not start after adding PHP to httpd.conf

Cause 1 of 3

The LoadModule line uses a module name that PHP 8 does not have

1Check

The first argument of LoadModule is the name of the module variable that the DLL exports, so a guessed name cannot work. The PHP manual shows php_module for PHP 8 and says the PHP 7 name was php7_module.

findstr /n /i "LoadModule" C:\Apache24\conf\httpd.conf

2Fix

Change the name to php_module, keep the DLL that belongs to PHP 8, and use the handler block from the manual.

LoadModule php_module "c:/php/php8apache2_4.dll"
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>
PHPIniDir "c:/php"

3Verify

The syntax test now ends in Syntax OK, and the module list contains PHP.

C:\Apache24\bin\httpd.exe -t
C:\Apache24\bin\httpd.exe -M | findstr /i php

Confirmed by php.net

Did this fix it?

Cause 2 of 3

The PHP folder holds the Non Thread Safe build, which has no Apache module

1Check

The manual says that the apache2handler SAPI needs the Thread Safe (TS) build of PHP. A zip marked Non Thread Safe does not meet that requirement.

dir C:\php\php8apache2_4.dll

2Fix

Download the Thread Safe zip of the PHP version you want, unpack it into a clean folder, and point LoadModule at the php8apache2_4.dll inside it.

LoadModule php_module "c:/php/php8apache2_4.dll"

3Verify

The DLL exists and the syntax test passes.

dir C:\php\php8apache2_4.dll
C:\Apache24\bin\httpd.exe -t

Confirmed by php.net

Did this fix it?

Cause 3 of 3

Backslashes or a wrong folder in the path

1Check

The manual tells you to use forward slashes in Apache's configuration files on Windows, and to put the real PHP location in the LoadModule line.

findstr /n /i "php8apache2_4" C:\Apache24\conf\httpd.conf

2Fix

Write the path with forward slashes and point it at the folder that really contains the DLL.

# wrong
LoadModule php_module "c:\php\php8apache2_4.dll"
# right
LoadModule php_module "c:/php/php8apache2_4.dll"

3Verify

Run the syntax test again, then restart Apache.

C:\Apache24\bin\httpd.exe -t

Confirmed by php.net

Did this fix it?

How do I stop it coming back?

  • After a PHP major upgrade, re-read the install page of the manual and compare it with httpd.conf line by line.
  • Run httpd.exe -t before every restart, so a typo fails in the console and does not stop the service.
  • Keep PHP in a short path such as c:/php, with no spaces, and reference it only from one place.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.