Linux – Apache Virtual Hosts Not Working

apache-2.2linuxvirtualhost

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>

Best Answer

remove the NameVirtualHost *:80 or comment it #NameVirtualHost

Related Topic