Web server configuration question -- this has to do with stuff that happens at config time, i.e. when the server reads the config files. For Apache, this happens when you do
service apache2 restart or
I would like to check for the existence of a file without actually including it. There should be an error identifying the file if it isn't found.
Does either Apache or Nginx support such a thing?
@woozle https://httpd.apache.org/docs/2.4/mod/core.html#iffile that what you are looking for?
Not quite sure how you can manually send a debug message to the log though...
@FiXato Aha! Yes, that looks like it should work.
When you run
apachectl configtest, it puts any error messages on the console, which is all I need.
@FiXato ...oh, but I see what you mean: it only does a thing if the file does exist; what I need is for something to happen if it does not...
Will poke around with this.
The filename in the section directive can take the same forms as the test variable in the section, i.e. the test can be negated if the ! character is placed directly before filename.
@woozle it's hacky, but I guess you could then do an include on an actually non-existing file with the error message as filename?
@FiXato It's a bit jank, but this seems to work:
have some bad syntax to throw an error
@woozle https://httpd.apache.org/docs/2.4/mod/core.html#error can be used to generate a custom error message and config parsing.
@meena Thing is, I need the check to happen without restarting Apache -- because if the changes give an error during startup processing, then Apache won't restart, and All The Things go down (not just whichever sites are borked).
This is what
apachectl is good for: it checks to see if the config "compiles" successfully, so at least I know I can restart Apache.
On the internet, everyone knows you're a cat — and that's totally okay.