Setting Up Multiple VirtualHosts on a single IP

I have a personal web server I’m trying to configure for multiple domains. However, I’m having trouble getting the configuration just right. The current problem is that both domains redirect to /home/www/public_html.

I have 2 domains pointing to a single IP (my servers IP).

Below are my virtualhosts in my config file (with dummy ip/domain names).


User apache
Group apache

ServerAdmin admin@domain1.org
ServerName domain1.webhop.net
DocumentRoot "/home/www/public_html"
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory "/home/www/public_html">
    Options Indexes FollowSymLinks MultiViews
    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_userdir.c>
    UserDir disable
</IfModule>

NameVirtualHost 11.11.11.11:80

<VirtualHost *:80>
        ServerName domain1.webhop.net
        ServerAdmin webmaster@domain2.org
        DocumentRoot /home/www/public_html/
</VirtualHost>

<VirtualHost *:80>
     DocumentRoot /home/sandbox/public_html
     ServerName domain2.dyndns.org
     <Directory "/home/sandbox/public_html">
          allow from all
          Options +Indexes
     </Directory>
</VirtualHost>


I receive this error when restarting the apache server:

[Sun Oct 17 10:28:05 2010] [warn] default VirtualHost overlap on port 80, the first has precedence
[Sun Oct 17 10:28:05 2010] [warn] NameVirtualHost 11.11.11.11:80 has no VirtualHosts

I can eliminate these errors by adding the IP to the virtualhost header. But, the apache documentation seems to state I should have *:80 unless I’m misreading it.

I appreciate any suggestions you may be able to offer. Server administration isn’t my forte and I feel like I’ve tried every possible combination of Virtualhost settings.

Thanks.

You should use the same for NameVirtualHost and VirtualHost.
So either use NameVirtualHost *:80 and VirtualHost *:80 or NameVirtualHost 1.1.1.1:80 and VirtualHost 1.1.1.1:80
It’s not mix and match :slight_smile: