How to load mod_version only if it isn’t built in to apache

apache-2.2apache-2.4

Apache 2.4 seems to have mod_version built in. Trying to load it with:

LoadModule version_module /usr/lib/apache2/modules/mod_version.so

gets an error:

Syntax error on line 26 of /home/ysth/src/conf/apache2.conf: module version_module is built-in and can't be loaded

(and the mod_version.so file doesn't exist anyway).

I have a number of standalone apache configuration files used to run various services, so the normal mods_enabled directory isn't suitable. I want to use IfVersion to have the same conf file used for both apache2.2 and apache2.4. How can I load mod_version only for apache2.2?

Best Answer

You can conditionally load it if it isn't already:

<IfModule !version_module>
LoadModule version_module /usr/lib/apache2/modules/mod_version.so
</IfModule>