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

I have added 2 virtual hosts to my apache2 conf file as below:

<VirtualHost *:80>
    DocumentRoot /var/www/html/site1
    ServerName www.site1.com
    ServerAlias site1.com
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot /var/www/html/site2
    ServerName www.site2.com
    ServerAlias site2.com
</VirtualHost>

I then got the error after restarting apache i get:

[warn] default VirtualHost overlap on port 80, the first has precedence

Searched google and they said to uncomment the line below, so I did:

NameVirtualHost *:80

Restart, and now I don't get the error, but both sites go to the first site.

running Centos5. How do I fix this problem?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You definitely want NameVirtualHost uncommented. That tells your server to server different virtual hosts based on the Doman Names used to reach it. That's why you see all requests go to the first site when it's removed.

share|improve this answer
    
Yea, I have done that and it still doesn't work. –  David Dec 17 '09 at 14:04
    
Does it not properly serve up site2.com even with it? It really looks like your warning is just stating that your first VirtualHost is the default site for unmatched names. Which is essentially just how Virtual Hosts work. –  Christopher Karel Dec 17 '09 at 14:08
    
After uncommented that line, i don't get a warning and both sites still go to site1 –  David Dec 17 '09 at 14:25
    
Is it possible that your browser has just cached the content from site1 under site2's domain? Try clearing your cache or doing a proper refresh. (ctrl+F5) –  Christopher Karel Dec 17 '09 at 16:07

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.