Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to add another virtualhost to an existing list of hosts (/etc/apache2/sites-availible/default). Here is a partial copy of the current setting:

<VirtualHost *> (<-- currently working)
 ServerAdmin cdv@nyenrode.nl
 Servername nyenrodejazznight.nl
 DocumentRoot /home/nrjazznight/html
        <Directory "/home/nrjazznight/html">
        AllowOverride None
        Order allow,deny
        Allow from all
        </Directory>
</VirtualHost>

<VirtualHost *> (<-- added and not working)
 ServerAdmin cdv@nyenrode.nl
 ServerName ncvlustrum.nl
 ServerAlias www.ncvlustrum.nl
 DocumentRoot /home/lustrum/html
        <Directory "/home/lustrum/html">
        AllowOverride None
        Order allow,deny
        Allow from all
        </Directory>
</VirtualHost>

It was my hope that it would work properly when I just copied the setting from an existing one and used it for a new one. This however, resulted in the problem that A. Internally the new website is redirected to the default website of Apache and B. ncvlustrum.nl is working externally, however www.ncvlustrum.nl gets redirected to the default page (same as A). The rest of the sites are all working (couple of 6 websites) with the settings looking just like the one I added. Did I miss something?

Thank you in advance!

Additional information:

ncv:/home/robbert# clear
ncv:/home/robbert# source /etc/apache2/envvars ; /usr/sbin/apache2 -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:*                    is a NameVirtualHost
         default server ncv.campus.nyenrode.nl (/etc/apache2/sites-enabled/000-default:2)
         port * namevhost ncv.campus.nyenrode.nl (/etc/apache2/sites-enabled/000-default:2)
         port * namevhost nyenroderally.nl (/etc/apache2/sites-enabled/000-default:129)
         port * namevhost hvtuinfeest.nl (/etc/apache2/sites-enabled/000-default:140)
         port * namevhost nyenrodejazznight.nl (/etc/apache2/sites-enabled/000-default:151)
         port * namevhost ncvlustrum.nl (/etc/apache2/sites-enabled/000-default:162)
         port * namevhost nieuwecompagnievanverre.nl (/etc/apache2/sites-enabled/000-default:174)
         port * namevhost checkout.nieuwecompagnievanverre.nl (/etc/apache2/sites-enabled/000-default:185)
         port * namevhost rugby.nyenrode.nl (/etc/apache2/sites-enabled/000-default:196)
         port * namevhost dezilverenrijder.nl (/etc/apache2/sites-enabled/000-default:207)
         port * namevhost www.dezilverenrijder.nl (/etc/apache2/sites-enabled/000-default:218)
         port * namevhost zilverenrijder.nl (/etc/apache2/sites-enabled/000-default:229)
         port * namevhost www.zilverenrijder.nl (/etc/apache2/sites-enabled/000-default:240)
         port * namevhost ondernemend.nyenrode.nl (/etc/apache2/sites-enabled/000-default:251)
         port * namevhost ncv.campus.nyenrode.nl (/etc/apache2/sites-enabled/000-default.save:2)
         port * namevhost www.nyenroderally.nl (/etc/apache2/sites-enabled/000-default.save:73)
         port * namevhost ncv.campus.nyenrode.nl (/etc/apache2/sites-enabled/000-default.save.1:2)
         port * namevhost www.nyenroderally.nl (/etc/apache2/sites-enabled/000-default.save.1:82)
         port * namevhost www.hvtuinfeest.nl (/etc/apache2/sites-enabled/000-default.save.1:93)
         port * namevhost www.nyenrodejazznight.nl (/etc/apache2/sites-enabled/000-default.save.1:104)
         port * namevhost ncv.campus.nyenrode.nl (/etc/apache2/sites-enabled/000-default.save.2:2)
         port * namevhost nyenroderally.nl (/etc/apache2/sites-enabled/000-default.save.2:129)
         port * namevhost hvtuinfeest.nl (/etc/apache2/sites-enabled/000-default.save.2:140)
         port * namevhost nyenrodejazznight.nl (/etc/apache2/sites-enabled/000-default.save.2:151)
         port * namevhost ncvlustrum.nl (/etc/apache2/sites-enabled/000-default.save.2:162)
         port * namevhost nieuwecompagnievanverre.nl (/etc/apache2/sites-enabled/000-default.save.2:174)
         port * namevhost checkout.nieuwecompagnievanverre.nl (/etc/apache2/sites-enabled/000-default.save.2:185)
         port * namevhost rugby.nyenrode.nl (/etc/apache2/sites-enabled/000-default.save.2:196)
         port * namevhost dezilverenrijder.nl (/etc/apache2/sites-enabled/000-default.save.2:207)
         port * namevhost www.dezilverenrijder.nl (/etc/apache2/sites-enabled/000-default.save.2:218)
         port * namevhost zilverenrijder.nl (/etc/apache2/sites-enabled/000-default.save.2:229)
         port * namevhost www.zilverenrijder.nl (/etc/apache2/sites-enabled/000-default.save.2:240)
         port * namevhost ondernemend.nyenrode.nl (/etc/apache2/sites-enabled/000-default.save.2:251)
Syntax OK
ncv:/home/robbert# a2ensite ncvlustrum.nl
ERROR: Site ncvlustrum.nl does not exist!
ncv:/home/robbert# pico /etc/apache2/ports.conf
  GNU nano 2.0.7                                           File: /etc/apache2/ports.conf

Listen 80
Listen 443
share|improve this question
    
please show us the output of source /etc/apache2/envvars ; /usr/sbin/apache2 -S which will give us a full picture of your VirtualHost configuration. –  stew Feb 8 '12 at 16:33
    
when you say "Internally" Do you mean that the site is being accessed by a different hostname? if so, what hostname? –  stew Feb 8 '12 at 16:34
    
Did you run a2ensite or symlink it over to enabled? –  Zoredache Feb 8 '12 at 16:49
    
You need to remove the .save files from sites-enabled. See the edit on my answer. –  Shane Madden Feb 8 '12 at 19:53

1 Answer 1

Since you have specified your vhosts as <VirtualHost *>, then you'll need to have your NameVirtualHost directive match; you need:

NameVirtualHost *

By default on Debian there's a NameVirtualHost *:80 directive in ports.conf, which won't work for these vhosts - change it to match your vhosts and you should be good to go. As stew mentioned in a comment, you can confirm that this is the case with the -S option.

Edit: From your additional info, it looks like you have two copies loading (and competing to be the one that serves requests); /etc/apache2/sites-enabled/000-default.save.2:162 and /etc/apache2/sites-enabled/000-default:162.

Seems that the .save is a backup file; get it out of sites-enabled, as everything in there is live configuration. Then make sure to restart Apache after making the necessary changes.

share|improve this answer
    
Removed all of the backups, still not working =( –  Menno Hamburg Feb 9 '12 at 11:26
    
Can you clarify the behavior that you're seeing? You said it 'redirects' - does the URL in the browser's address bar change to a different host? Also, you mentioned that the behavior is different between inside and outside - can you tell us what your DNS setup looks like? –  Shane Madden Feb 9 '12 at 16:09
    
right now iam using the following config file only: dpaste.com/700533. The problem is that some sites (like www.dezilverenrijder.nl) are going to the right site, and some (like ncvlustrum.nl) are being redirect to the default site (ncv.nyenrode.nl/web/). Since I removed some of the config files, even more sites are now redirected towards the default website. –  Menno Hamburg Feb 9 '12 at 21:57
    
Can you clarify the client behavior you're seeing in terms of redirection, as well as the DNS configuration? –  Shane Madden Feb 10 '12 at 3:39
    
I might have found the problem: Firefox. Something in its cache forces the url to change to the default url. I have things up and running now. Guess there was nothing wrong with apache... –  Menno Hamburg Feb 15 '12 at 8:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.