Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm learning to configure name-based virtual host for apache 2.

Right now, my domain points to /var/www/index.html. I want it to point to my newly created /srv/www/

I currently have two files:

  • /etc/apache2/sites-available/default
  • /etc/apache2/sites-available/

This is what they look like:


NameVirtualHost myipaddr:80

<VirtualHost myipaddr:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
## other default directives


<VirtualHost *:80>
     DocumentRoot /srv/www/
     ErrorLog /srv/www/
     CustomLog /srv/www/ combined

I executed a a2ensite and restarted apache, but still points to the default /var/www/ directory. I guess apache is not registering my /etc/apache2/sites-available/ file?

Did I miss a step in my configuration and installation?

share|improve this question
up vote 0 down vote accepted

I am not sure that it is the problem, but the first thing that sticks out is that your are using an IP in your NameVirtualHost setting, and a wildcard in the for the You probably should use a wildcard for the NameVirtualHost and the default virtual host.

share|improve this answer
hey, that worked! Thank you! – John Oct 12 '09 at 16:47
  • you should set a different name for "default"


  • also you can set all NameVirtualHost and VirtualHost to *:80 just for uniformity of the config
share|improve this answer

Your Answer


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.