help with Virtual Hosts on Apache

Sven Richter sveri-list at gmx.de
Tue Mar 27 07:12:02 UTC 2007


On Tuesday 27 March 2007 01:52:21 Wade Smart wrote:
> 03262007 183 GMT-6 DST
>
> Im working on setting up joomla on my system. To get this installed
> though I had to setup virtual hosts. This way I can test various sites
> out.
>
> On this tutorial
> http://www.debuntu.org/2006/02/22/7-virtual-hosting-using-apache-2
> I followed the instructions to setting up a virtual host.
> Ill repost a very condensed version here:
>
> 1) cd /etc/apache2/sites-available
>
> 2) sudo gedit name.com.conf
>
> Paste:
> <VirtualHost dev.example.com>
>   ServerAdmin webmaster at localhost
>   ServerAlias www.dev.example.com
>   DocumentRoot /home/myuser/public_html/example.com
>   ScriptAlias /awstats/ /usr/lib/cgi-bin/
>   CustomLog /var/log/apache2/example.com-access.log combined
> </VirtualHost>
>
> 3) cd /etc/apache2/sites-enabled/
>
> 4) sudo ln -s /etc/apache2/sites-available/name.com.conf name.com.conf
>
> 5) sudo gedit /etc/hosts
>    add:
> 127.0.0.1 localhost.localdomain localhost dev.name.com www.dev.name.com
>
> 6) sudo /etc/init.d/apache2 reload
>
> So I did this with these specifics:
> <VirtualHost dale.com>
>   ServerAdmin webmaster at localhost
>   ServerAlias www.dale.com
>   DocumentRoot /var/www/public_html/example.com
>   ScriptAlias /awstats/ /usr/lib/cgi-bin/
>   CustomLog /var/log/apache2/example.com-access.log combined
> </VirtualHost>
>
> and under /etc/hosts I added
> 127.0.0.1 sam.com dale.com
>
> Problem is, what happens when I add a second and a third entry?
>
> I created a second entry and received this error after restarting
> apache:
>
> [Mon Mar 26 18:34:24 2007] [warn] VirtualHost dale.com:0 overlaps with
> VirtualHost sam.com:0, the first has precedence, perhaps you need a
> NameVirtualHost directive
>
> Am I doing this wrong?
>

I can remember that long ago i was fiddeling around with
Virtual Hosts too.

My solution was the following:

Add the following lines in /etc/apache2/sites-available/default

<VirtualHost *>

 ServerName sveri
 DocumentRoot /var/www/privat/

</VirtualHost>

<VirtualHost *>

ServerName alcoholics
DocumentRoot /var/www/alcoholics/

</VirtualHost> 

and add in /etc/hosts
127.0.0.1 sveri 
127.0.0.1 alcoholics

This still works for me.


Greetings
Sven Richter




More information about the ubuntu-users mailing list