9.23.2014

Apache 2.4.10 appears to ignore DocumentRoot in httpd.conf

I needed to update my webserver from an ancient version of Apache 2.2 to the latest (2.4.10 at the time of this writing). I knew some access controls had changed between 2.2 and 2.4 but I figured I'd read the update guide and be all set. I downloaded the bins, set up the windows service, tweaked httpd.conf and was promptly greeted by a 403 forbidden.

My httpd.conf looked something like this:

# default configuration options for all environments

DocumentRoot "w:/"
<Directory "w:/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options -Indexes -FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted

</Directory>

And yet the 403 errors in my error.log looked like this:

[Tue Sep 23 21:28:11.212375 2014] [authz_core:error] [pid 11608:tid 1192] [client 127.0.0.1:1931] AH01630: client denied by server configuration: C:/Program Files/Apache Software Foundation/Apache24/htdocs/

What?! I set my DocumentRoot to "W:/", why is it trying to access stuff at .../Apache24/htdocs ?! After much wailing and gnashing of teeth and Googling, I ran httpd.exe with the -S option to dump the runtime config. I noticed a "VirtualHost configuration:" entry...
What?! I didn't set up any virtual hosts! I quickly vim'd (gvim in this case) C:\...\conf\extra\httpd-vhosts.conf and saw the culprit:
<VirtualHost _default_:80>
DocumentRoot "${SRVROOT}/htdocs"
#ServerName www.example.com:80
</VirtualHost>

The virtual host config was overriding the DocumentRoot I had so carefully set in httpd.conf. I modified the DocumentRoot to match the entry in httpd.conf and all was well!