Super User is a question and answer site for computer enthusiasts and power users. 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 probably have something set up wrong. Seems I always have problems trying to configure my Virtual Hosts correctly.

I'm getting this error after restarting Apache:

Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
[Wed Oct 14 17:39:17 2009] [warn] VirtualHost site1.local:0 overlaps with VirtualHost site2.local:0, the first has precedence, perhaps you need a NameVirtualHost directive

Why is it using for ServerName? And why isn't my site2.local virtual host working?

Here's my hosts file:

# /etc/hosts   localhost site1.local site2.local   andrew-laptop

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

In /etc/apache2/sites-available I have 3 files: default, site1.local, and site2.local


NameVirtualHost *
<VirtualHost *>
    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

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
    	AllowOverride None
    	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    	Order allow,deny
    	Allow from all

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from ::1/128



<VirtualHost site1.local>
    ServerAdmin webmaster@localhost
    ServerName admin
    DocumentRoot /home/andrew/Projects/site1/public
    CustomLog /var/log/apache2/site1-access.log combined
    <Directory /home/andrew/Projects/site1/public>
        Options FollowSymLinks
    AllowOverride All


<VirtualHost site2.local>
    ServerAdmin webmaster@localhost
    ServerName admin
    DocumentRoot /home/andrew/Projects/site2/public
    CustomLog /var/log/apache2/site2-access.log combined
    <Directory /home/andrew/Projects/site2/public>
        Options FollowSymLinks
    AllowOverride All

If any of this seems wrong, please let me know. Please help me figure out what is wrong with my setup.

share|improve this question
up vote 1 down vote accepted

I believe you should be using site1.local / site2.local as your ServerName parameters in your virtual host least that's what works for me.

The ServerName default is likely being set in apache2.conf.

share|improve this answer
And change change the <VirtualHost site1.local> & <VirtualHost site2.local> to <VirtualHost *> – jmohr Oct 15 '09 at 2:58

Here's one problem: in /etc/hosts, your localhosts line is wrong. You have this:

# /etc/hosts   localhost site1.local site2.local

You need to have this:

# /etc/hosts   localhost.localdomain localhost

The top line is important. You can assign site1.local and site2.local to nearly anything else, but the top line needs to include both localhost.localdomain and localhost.

I'm not sure what black magic is responsible, but things break weirdly in Ubuntu 9.04 and Debian 5.0.3 if that line gets changed to anything else. My recent Debian install had the same Apache errors (plus some other interesting breakages) until I rolled back my own changes to that line.

Since you still need to define site1.local and site2.local, you could do it like this:   andrew-laptop site1.local site2.local

But Apache might prefer different IP addresses for the sites, so you'd probably be better off doing it this way:   andrew-laptop   site1.local   site2.local

The network is loopback, so you can pick any 127.x.x.x address you like for them.

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.