1

EDIT: I was able to get this to work. There was a VirtualHost entry in httpd.conf that was effecting the Virtual Hosts in my vhosts.conf file.

I am trying to set up a CentOS server and configure it with two virtual hosts. This server is going to be replacing a Solaris server with the same settings. On the Solaris (current) server, the virtual hosts work, but on the new server, the first one is called regardless of what sent it (modifying hosts file).

SSL virtual host works.

I have tried to add "NameVirtualHost *:80", but get

[Thu Jun 30 14:43:38 2011] [warn] default VirtualHost overlap on port 80, the first has precedence [Thu Jun 30 14:43:38 2011] [warn] NameVirtualHost *:80 has no VirtualHosts

Does anyone have any ideas?

EDIT: I forgot to post my configurations.

NameVirtualHost *:80
...
<VirtualHost *:80>
DocumentRoot "/var/www/html/domain1"
ServerName domain1
ServerAlias www.domain1

AllowOverride All
Options None
Order allow,deny
Allow from all

DirectoryIndex index.html index.php
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/html/domain2"
ServerName domain2
ServerAlias www.domain2

AllowOverride All
Options None
Order allow,deny
Allow from all

DirectoryIndex index.html index.php
</VirtualHost>

3 Answers 3

1

remove the NameVirtualHost *:80 or comment it #NameVirtualHost

2
0

It'd be really helpful for you to post the configurations. That said, you likely have the following as your vhost definitions:

<VirtualHost _default_:80>

When your NameVirtualHost *:80 block needs to match your VirtualHost definitions. Try this:

<VirtualHost *:80>
1
  • Thanks for your response. Posted config above. I have the *:80 in the virtual host directive. Jun 30, 2011 at 19:02
0

It sounds like you've defined both of your VirtualHosts as:

<VirtualHost _default_:80>
    ServerName www.mysite.com

...
</VirtualHost>

and

<VirtualHost _default_:80>
    ServerName www.myothersite.com

...
</VirtualHost>

This is not what you want, you want two VirtualHost that listen on *:80, and use Name-Based Virtual Hosting, like this:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.mysite.com

...
</VirtualHost>

<VirtualHost *:80>
    ServerName www.myothersite.com

...
</VirtualHost>

The _default_:80 definition tells Name-Based Virtual Hosting to use this VirtualHost when no other VirtualHost matches by name or unique IP:Port pair.

1
  • Thanks for your response. Posted config above. I have the *:80 already. Jun 30, 2011 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .