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?
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.
I already fix this proble with CWP
just go to /usr/local/apache/conf/sharedip.conf
check this put * in your ip server
then go to /usr/local/apache/conf.d/vhost.conf and be sure of each virtualhost looks like this
this works for me!