0

I have an apache2 setup (Ubuntu 16, Apache 2.4.18) with a number of virtual hosts defined. Each virtualhost has it's own .conf file in /etc/apache2/sites-available with a softlink to /etc/apache2/sites-enabled.

All but one of the virtualhosts work correctly. I have triple checked that the ServerName matches the domain (it does), but when I go to that domain, I end up at DocumentRoot for the default virtualhost and I have no idea why. I also deleted and re-wrote the whole ServerName line in case there was some hidden control character.

I have done a diff between one of the working virtualhosts and the one that doesn't work, and the only differences are the DocumentRoot and the ServerName.

I have checked that there are no other virtual hosts with the same domain (the only other one is the SSL virtual host)

Is there anything else I can look for to help figure out the issue?

EDIT: As requested, the VH file (domain name/folder obscured and comments removed for brevity)

<VirtualHost *:80> ServerName MYDOMAIN.COM ServerAdmin [email protected] DocumentRoot /var/www/MYDOMAIN.COM ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

EDIT 2: I removed the default VH and restarted, then the problem VH worked fine. I re-added the default VH and restarted, and the problem VH continued to work fine for about 20 seconds, then it reverted to the same problem.

7
  • If you show us the VH in question maybe we can help Commented May 20, 2019 at 14:51
  • Did you check the Apache error log for any clues? Commented May 20, 2019 at 14:52
  • I will add it in a sec, but other than ServerName and DocumentRoot it's identical to a working one, so I suspect the problem is outside of the VH file, I just have no idea what it could be! Commented May 20, 2019 at 14:52
  • No errors in the apache error log Commented May 20, 2019 at 14:56
  • Where do you specify the <Directory> ...... block Commented May 20, 2019 at 14:58

1 Answer 1

0

As far as I can tell, the problem was happening because the domain was listed in the /etc/hosts file and set in /etc/hostname. Removing it from there seemed to fix the problem.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.