I've got a few sites configured as VirtualHosts using Apache that have been working fine for a while. I recently changed the hostname of the server to one of the domain names that was being served, and also added it to /etc/hosts pointing to the server's external IP address.
Since I did that, accessing the domain from my laptop takes me to Apache's default "It works!" page. If I remove 000-default from /etc/apache2/sites-enabled/, it displays the correct site. Trying to access the site with the 'www.' prefix takes me to the correct site whether or not 000-default is in sites-enabled.
Based on all of that, I'm guessing the default config is serving up the default page because of how I've configured the hostname or /etc/hosts (or both), but I can't figure out how to disable that while leaving those settings as they are. Any suggestions welcome!
Edit - My current VirtualHost config looks like this:
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin [email protected]
DocumentRoot /srv/www/domain
ErrorLog /srv/www/domain/logs/error.log
CustomLog /srv/www/domain/logs/access.log combined
</VirtualHost>
To summarize: I have several VirtualHosts set up, and this is the only one not working properly. I can access http://www.domain.com just fine, but http://domain.com takes me to Apache's default "It works!" page. If I disable the 000-default config it shows the proper page. This only started happening after I set the hostname of the server to domain.com and added a line to /etc/hosts pointing domain.com to the server's external IP address. I'd like to leave those that way if possible.
Edit: I ran apache2ctl -S
since /usr/sbin/apache2 -S
gave me "apache2: bad user name ${APACHE_RUN_USER}". Here's the output:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server domain.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost domain.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost other.com (/etc/apache2/sites-enabled/other:1)
port 80 namevhost another.com (/etc/apache2/sites-enabled/another:1)
port 80 namevhost domain.com (/etc/apache2/sites-enabled/domain:1)
Syntax OK
apache2ctl -S
showed us that ourdefault server
for *.443 was our troublesome domain, but we also found it listed in/etc/resolv.conf
undersearch troublesome-domain.com