Russell Davis Russell Davis - 1 month ago 10
Apache Configuration Question

How do I include a file in Apache config without generating an error when it doesn't exist?

This is for a shared config file that should include another file if it exists, but still work otherwise. If I do

Include foo.conf


and foo.conf doesn't exist, apache will complain:

could not open document config file /etc/httpd/conf/foo.conf

Answer

I came up with a clever solution, though there may be a better way. Put one of the characters in brackets so Apache will treat it as a glob pattern, which is allowed to match zero files without causing an error. E.g.:

Include foo.con[f]