I'm trying to find where a reference to /var/www/html
still exists in my Apache configuration. When I run apache2ctl -S
it says Main DocumentRoot: "/var/www/html"
, but none of my virual hosts or my main Apache config file point to that directory.
I have tried searching all of the config files using grep -r "var/www/html" /etc/apache2/
but it returns nothing.
There is no <Directory>
entry for that path in my /etc/apache2/apache2.conf
file (there is one for /var/www
, under which I store the virtual hosts).
This configuration quirk bothers my OCD, but I also frequently see these entries in my Apache error log:
[Fri Jun 28 18:19:53.424619 2019] [autoindex:error] [pid 22665]
[client 209.222.82.167:47376] AH01276: Cannot serve directory
/var/www/html/: No matching DirectoryIndex
(default.php,index.php,index.html,index.htm) found, and server-generated
directory index forbidden by Options directive
How does Apache decide what the main documentroot is, and how can I change it?
EDIT:
For my sites-available/sites-enabled, I have four files, 000-default.conf
, 000-default-le-ssl.conf
, 000-www-default.conf
, and 000-www-default-le-ssl.conf
. The 000-default.conf
is a redirect set by certbot to point to the https site and has no DocumentRoot directive. The 000-www-default.conf
is identical to 000-default.conf
but for the ServerName (one has www and the other doesn't); the same pattern follows for000-www-default-le.conf
and 000-default-le.conf
.
Here is the output of some things I've tried:
apache2ctl -V
: https://pastebin.com/R4ykihLvapache2ctl -S
: https://pastebin.com/JaEGQLgS$ sudo grep -r "/var/www/html" /
(partial, I stopped it after almost 5 hours): https://pastebin.com/9iJyAH9JAs @Nic3500 pointed out, the /var/www/html
is the default value for the main DocumentRoot. Changing virtual host configurations does not affect this. However, adding a DocumentRoot directive to apache.conf
does change it as reflected in the output of apache2ctl -S
.
In other words, my main DocumentRoot was unconfigured and the default value was used until I explicitly defined it in a global configuration file.