The Apache Haus Forum

Forum Topics => Apache 2.4 => Topic started by: Waccoon on June 01, 2015, 05:07:58 AM

Title: DocumentRoot being overwritten in VirtualHost config
Post by: Waccoon on June 01, 2015, 05:07:58 AM
Hello.  While upgrading from Apache 2.2 to 2.4, I've discovered a problem with the Apache Haus VC9 build of Apache 2.4.12 which does not exist in other Windows binary builds of Apache.  Apparently, Apache Haus is enabling VirtualHosts by default, and this causes the main DocumentRoot declaration to be overwritten in the httpd-vhosts.conf file.

I use a dedicated partition of my SSD to host my DocumentRoot.  Upon installation, I changed my DocumentRoot in the httpd.conf file from "${SRVROOT}/htdocs" to "W:/", and updated the directory permissions for "W:/" accordingly.

The server insisted on defaulting to "${SRVROOT}/htdocs" and kept showing me the default Welcome page.  I eventually found out that the VirtualHosts file is being included at the end of the main config file, resulting in the DocumentRoot being overwritten, as follows:

Code: [Select]
<VirtualHost _default_:80>
DocumentRoot "${SRVROOT}/htdocs"

Therefore, it is necessary to copy a custom DocumentRoot setting into both config files for it to work.  As I've never used VirtualHosts before, this took me a few hours to figure out.

When searching the Internet for assistance, I discovered that other people having this issue were all using a Windows version of Apache.  I then checked some other Windows builds and found that only the Apache Haus version has this issue.  Either the installation instructions should be updated to take the default VirtualHosts setting into account, or the config files should be updated to avoid the duplicate DocumentRoot declaration.

Title: Re: DocumentRoot being overwritten in VirtualHost config
Post by: Gregg on June 01, 2015, 05:32:31 AM
Ok, what it does however is heads off an even bigger issue I've seen people have more times than I can count which is "Can't get virtual hosts to work."

You do make a good point however. Looking at he readme it could a note that if you only want a single host, comment out the Include httpd-vhosts.conf line. I'll have a look over our current config as well and see where it maybe could use some improvement.

Thanks for bringing this up.
Title: Re: DocumentRoot being overwritten in VirtualHost config
Post by: Gregg on June 05, 2015, 05:38:05 AM
Actually, what I have done is not load httpd-vhosts.conf by default. I had already noted the importance of the first vhost being a partial duplicate of the main host (in 2.4 anyway). I have done same including the note in 2.2 as well so all downloads from 2.2.30 & 2.4.13 on should not have this problem you had, nor the problem I was trying to avoid in the first place.

Again, thanks for reporting this. I wish the others would have reported it here long ago.