Solution to a problem with VirtualHosts on Debian Lenny (Default Virtualhost opening by default overwritting the rest of the configured VirtualHosts)

Wednesday, 17th February 2010

Configuring some Virtualhosts on a Debian server I administrate has led me to a really shitty problem. The problem itself consisted in that nomatter what kind of the configured VirtualHosts on the server I try to access the default one or the first one listed among Virtualhosts gets accessed. Believe me such an Apache behaviour is a real pain in the ass! I went through the VirtualHosts configurations many without finding any fault in them, everything seemed perfectly fine there. I started doubting something might prevent VirtualHosts to be served by the Webserver. Therefore to check if VirtualHosts configurations are properly loadedI used the following command:

debian-server:~# /usr/sbin/apache2ctl -S

Guess what, All was perfectly fine there as well. The command returned, my webserver configured VirtualHosts as enabled (linked) in: /etc/apache2/sites-enabled I took some time to ask in irc.freenode.net #debian channel if somebody has encountered the same weirdness, but unfortunately noobody could help there. I thinked over and over the problem and I started experimenting with various stuff in configurations until I got the problem.

The issue with non-working Virtualhosts in Debian lenny was caused by;
wrong NameVirtualHost *:80 directive
It’s really odd because enabling the directive as NameVirtualHost *:80 would report a warning just like there are more than one NameVirtualHost variable in configuration, on the other hand completely removing it won’t report any warnings during Apache start/restart but same time VirtualHosts would still be non-working.

So to fix the whole mess-up with VirtualHosts not working I had to modify in; my /etc/apache2/sites-enabled/000-default as follows;

NameVirtualHost *:80 changes toNameVirtualHost *

The rest of the Virtualhost stays the same;
This simple thing eradicated the f*cking issue which tortured me
for almost 3 hours! ghhh

Share this on:

Download PDFDownload PDF

Tags: , , , , ,

4 Responses to “Solution to a problem with VirtualHosts on Debian Lenny (Default Virtualhost opening by default overwritting the rest of the configured VirtualHosts)”

  1. wg says:
    Firefox 3.5.9 Firefox 3.5.9 Windows XP Windows XP
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9 (.NET CLR 3.5.30729)

    After searching for hours for the same problem… your post resolve it!! 😉

    Just two chars!
    F………………………..KKKK 😉

    View CommentView Comment
    • admin says:
      IceWeasel 3.5.10 IceWeasel 3.5.10 GNU/Linux x64 GNU/Linux x64
      Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100623 Iceweasel/3.5.10 (like Firefox/3.5.10)

      Hey It’s a pleasure for me that this post helped you out.

      View CommentView Comment
  2. eddie says:
    Internet Explorer 8.0 Internet Explorer 8.0 Windows Vista x64 Edition Windows Vista x64 Edition
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.30729; .NET4.0C; .NET CLR 3.5.30729)

    Hi,

    Your postrs helped me with things before. Now I have installed lenny debian 5 with the eaccelerator and ispconfig3 – i updated everything (maybe that was a mistake) – I get the same no virtual hosts error message – and what is worse – when I add dns zones and then sites to my ispconfig3 admin area – the domains are NOT added in /var/www – ! What does this mean? Can you think of a fix for this? Isn’t each domain – after adding the DNS ZOne and the site in the ISPConfig3 manager – isn’t each domain suppossed to be added to the /var/www/ ?

    I appreciate your advice about this. Thanks, Eddie

    View CommentView Comment
    • admin says:
      Epiphany 2.29.92 Epiphany 2.29.92 Debian GNU/Linux x64 Debian GNU/Linux x64
      Mozilla/5.0 (X11; U; Linux x86_64; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Safari/531.2+ Debian/squeeze/sid () Epiphany/2.29.92

      Hi Eddie,
      Each Virtualhost domain should have it’s own directory like for instance /var/www/myvirtualdomain /var/www/anothervirtualdomain etc.
      I have no clue what is your situation neither what the ispconfig3 config admin are. If ISPConfig3 is some kind of web based virtualhost configuration software then my advice is you contact either the authors of the soft for help or contact your web hosting company.

      Wish you luck,
      Georgi

      View CommentView Comment

Leave a Reply

CommentLuv badge