brianmearns
brianmearns

Reputation: 9967

Custom errors in apache config files (not error pages)

I'm not looking to create custom error pages, but to actually issue error messages when the config file is parsed. Specifically, I want to use an <IfModule> to throw up an error if the module hasn't been loaded, so it's easier to debug.

Upvotes: 0

Views: 261

Answers (2)

MHolz
MHolz

Reputation: 21

For Httpd 2.4 see http://httpd.apache.org/docs/2.4/en/mod/core.html#error

For older versions

<IfModule !mod_deflate.c>
     Mod_deflate_not_enabled.
</IfModule>

will raise something like

Syntax error on line 7 of /etc/apache2/sites-enabled/000-default:
Invalid command 'Mod_deflate_not_enabled.', perhaps misspelled ...
   ...fail!

when you reload the server config.

Upvotes: 1

Wrikken
Wrikken

Reputation: 70490

This is the only kludgy thing I could think of (and requires mod_rewrite enabled):

<IfModule !mod_deflate.c>
        ErrorDocument 500 "mod_deflate isn't available"
        RewriteEngine On
        RewriteRule .* - [R=500]
</IfModule>

If you find a better way to 'trigger' errors, I'm certainly interested ;)

Upvotes: 1

Related Questions