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 apachectl configtest.

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?

· · Web · 3 · 1 · 1

Also, I would like to see step-through debugging of every configuration file. Do you think your associates could arrange that for me, Mister Morden.

Show thread

@woozle 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.

@FiXato Yah, so I just need to find a way to throw an error inside the section.

@woozle without actually throwing a failure state I guess?

@FiXato That would be fine. Just something to generate an error message.

@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?

@woozle I just don't understand I can't find an explicit DEBUG directive or something similar...

@FiXato It's a bit jank, but this seems to work:

<IfFile !${HomeDir}/cgi-bin/php7.4.cgi>
have some bad syntax to throw an error

@woozle @FiXato y'all, i would've put this in the service file (systemd, rc, launchd, etc)

@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.


@woozle I was browsing through nginx config docs recently and didn't come across anything like that, sorry.

@gidi We found a solution for Apache, at least. I keep hearing that Nginx is better, so there probably is some way to do it.

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!