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

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

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

  1. [...] 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. More here [...]

  2. [...] the upgrade of Apache, my virtual hosts weren't working. A quick search via Google pointed me to this post – a quick edit of all of my host files and it was all working [...]

  3. wg says:

    After searching for hours for the same problem… your post resolve it!! ;-)

    Just two chars!
    F………………………..KKKK ;-)

  4. eddie says:

    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

    • admin Epiphany Debian GNU/Linux says:

      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

  5. wool rugs uk says:

    I like this website very much, Its a very nice situation to read and obtain info. “Repetition does not transform a lie into a truth.” by Franklin D. Roosevelt.

Leave a Reply