2

I am trying to load a module based on a condition. {PHPMODULENAME} is replaced in the config by the AMP Server I am using - so please don't get confused.

<If "'{PHPMODULENAME}' == 'php8_module'">
    LoadModule module1 "..."
</If>
<Else>
    LoadModule module2 "..."
</Else>

If the condition is true it should load module1 - because only then the module1 is available and module2 isn't. And vice versa.

However when I try to start Apache, it throws an error, because either module1 or module2 is missing. I know that - that's why I add the IF condition.

ESP32
  • 73
  • 7

1 Answers1

3

Apache httpd provides a specific conditional to test for the presence of a module :

The < IfModule > directive:

Description: Encloses directives that are processed conditional on the presence or absence of a specific module
Syntax: <IfModule [!]module-file|module-identifier> ... </IfModule>

HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • I was about to post the same, but I got the impression that the goal is not to check if a module is loaded, but to load a specific module if configured in some kind of external configuration management. – Gerald Schneider May 09 '23 at 16:14
  • I added the IFModule directive and now it works. It's strange that the parser rises an error for a missing module within an unresolved IF directive, but accepts if the missing module is listed within an unresolved IFModule. IMHO both should react the same way. Anyway, thank you guys! – ESP32 May 11 '23 at 14:54