Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been staring at this for an hour and I'm just not seeing it. I know it will be something stupid but I need some other eyes on this because mine aren't catching it.

Standard Unbuntu Linode box with Apache on it. I've got 2 sites configured so far, and for some reason the second virtual host is not working; the site for the first one comes up instead.

The apache2.conf, httpd.conf and ports.conf are all 'standard' and unedited.

The ports.conf file contains these lines:

NameVirtualHost *:80
Listen 80

The two sites are in separate config files, they've been linked into the enabled-sites directory using a2ensite. I've triple checked that they are linked to the correct directories. Both of which happen to be Wordpress sites. I've also made sure the wordpress configs are correct and pointing to two different databases (and further confirmed that if I disable the 'first' site the second site starts showing up).

At this point I think that for some reason the VirtualHost directive is being ignored, but I'm doing something stupid with syntax? I've seen examples of syntax that include the domain name in the VirtualHost directive but that seems to be out of date and that ServerName syntax like below is preferred (and I tried the other way to no avail). Here is site one:

<VirtualHost *:80>
ServerName imagethief.com
ServerAlias www.imagethief.com
DocumentRoot /var/www/imagethief.com/wordpress/
<Directory /var/www/imagethief.com/wordpress/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
</Directory>

ErrorLog /var/www/imagethief.com/log/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/www/imagethief.com/log/access.log combined
</VirtualHost>

And the second:

<VirtualHost *:80>
ServerName nutritioneer.com
ServerAlias www.nutritioneer.com
DocumentRoot /var/www/nutritioneer/wordpress/
<Directory /var/www/nutritioneer/wordpress/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
</Directory>

ErrorLog /var/www/nutritioneer/log/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/www/nutritioneer/log/access.log combined
</VirtualHost>

What am I missing?

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server imagethief.com (/etc/apache2/sites-enabled/imagethief.com:1)
     port 80 namevhost imagethief.com (/etc/apache2/sites-enabled/imagethief.com:1)
     port 80 namevhost nutritioneer.com (/etc/apache2/sites-enabled/nutritioneer.com:1)
Syntax OK
share|improve this question
2  
Your VirtualHost blocks match the NameVirtualHost directive (which would be the common issue there), and the names/aliases look good - no problems that I can see with that config. Since one site is getting requests for both hosts (and it changes based on which is enabled), it seems that NameVirtualHost isn't applying correctly - verify by just renaming site 2's symlink to be alphabetically before site 1 in the sites-enabled directory, and it will start getting all the requests, despite both still being enabled. Look for anything in apache's error log during startup. –  Shane Madden Sep 3 '11 at 23:24
    
is there any log on /var/www/nutritioneer/log/access.log and /var/www/imagethief.com/log/access.log if you access both site ? –  chocripple Sep 4 '11 at 3:21
    
For my edification can you post the output of this command source /etc/apache2/envvars ; apache2 -S? –  Zoredache Sep 4 '11 at 5:27

1 Answer 1

Found it. As I thought it was staring me in the face.

It is not a configuration error, instead it is head-slappingly stupid mistake; the second domain is not a .com, it is a .net domain, so while the DNS was resolving to the correct IP the browser headers were looking for a site that doesn't exist and was served the default instead.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.