Every single time I set up a new httpd installation, I struggle with the initial  VirtualHost / mod_proxy_fcgi / etc. configuration.

When I set up my virtual hosts and get a 404, I always turn to the logs, only to find:

  • access_log:

    ::1 - - [13/Sep/2019:21:33:57 +0200] "GET /phpinfo.php HTTP/1.1" 404 196

    That is, only that a 404 happened.

  • error_log:

    [Fri Sep 13 21:33:55.009444 2019] [mpm_prefork:notice] [pid 73200] AH00163: Apache/2.4.41 (Unix) configured -- resuming normal operations
    [Fri Sep 13 21:33:55.011901 2019] [core:notice] [pid 73200] AH00094: Command line: '/usr/local/opt/httpd/bin/httpd -D FOREGROUND'

    That is, nothing.

So I always end up doing the same thing: trial-and-error.

Is there any way I can instruct Apache to log every single step it tried before concluding it's a 404?

Something like:

  • no match for VirtualHost x
  • no match for VirtualHost y
  • match for VirtualHost z, file not found: /path/to/file

That is, something useful?


Yes. There possible approaches to solve your problem. In my opinion, the best one is to configure different ErrorLog and CustomLog directives per virtualhost, saving into independent files. Another one is to customize your log, inserting the virtualhost using the LogFormat masks (%v, for instance, to log the respective virtualhost). The problem with this method is that if you use some sort of Apache log analyzer, you may stumble into some sort of problem, or will have to configure it to match the new pattern.

Best regards.

  • Interesting, thanks. Could you please provide a sample configuration? – Benjamin Sep 13 at 20:36
  • 1
  • I mean, your answer would be more helpful (and would accumulate upvotes more easily, if that matters to you) if you actually included a ready-to-use configuration line. Otherwise, of course, I'll go to the docs. – Benjamin Sep 13 at 21:12
  • There is a ready-to-use configuration in the docs, Benjamin. ;) – Stefano Martins Sep 16 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.