Apache File Does Not Exist Error

I was getting a “File does not exist: /etc/apache2/htdocs” error in my default Apache error log. The error appeared every 5 minutes. All my sites were fine but this was getting annoying so it was time to do something about it.

Apache logo

Apache logoI spent some time over the past week killing some bugs and making some adjustments to my server. One of them was a message being logged to my default Apache error log (/var/log/apache2/error.log). The error was:

[Sun May 27 22:05:03 2012] [error] [client] File does not exist: /etc/apache2/htdocs

The error was being logged exactly on every five minute mark, no matter when the server was started. The interesting parts here are that none of my sites are configured to listen on the loopback address ( although some are set to run on any addresses. Also, /etc/apache2 is not the document root for any of my sites. All of my sites were working and were properly configured. A Google search showed I was not alone with the problem but had no good solutions

What I ended up doing is specifying a default document root for a directory that does exist. I used the default site for the server.

sudo nano /etc/apache2/conf.d/DefDocRoot

I put in one line:

DocumentRoot /valid/path/to/site/public

I reloaded the Apache configuration and the error went away. It seems like there’s a default site of some type configured into Apache. It might be something I configured but apache2ctl –S doesn’t show any syntax errors and all my sites seem fine.