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 want to run multiple domains on my server (only two at the moment). I already changed both nameservers to point to my server.

In the apache2.conf file I enabled "included sites-enabled".

My ports.conf file looks as follows

NameVirtualHost *:80
Listen 80
Listen 443

<VirtualHost xx.xx.xx.xx:443>
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/apache.pem
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key

    DocumentRoot /var/www/
    ErrorLog /var/log/error.log
    CustomLog /var/log/access.log combined

This is the setting for my main page.

My httpd.conf file looks like this


<VirtualHost xx.xx.xx.xx:80>
DocumentRoot /var/www/
ErrorLog /var/log/error.log
    CustomLog /var/log/access.log combined

<VirtualHost *:80>
    ServerAlias *
    DocumentRoot /home/user/www/

Options -Indexes All FollowSymLinks MultiViews

Last but not least my "secondDomain" file in "sites-avaiable"


    # Indexes + Directory Root.
    DirectoryIndex index.html
    DocumentRoot /home/user/www/secondDomain/htdocs/

    # CGI Directory
    ScriptAlias /cgi-bin/ /home/user/www/seoncDomain/cgi-bin/
    <Location /cgi-bin>
            Options +ExecCGI

    # Logfiles
    ErrorLog  /home/user/www/secondDomain/logs/error.log
    CustomLog /home/user/www/secondDomain/logs/access.log combined

I also get an error message, everytime I restart the apache server, saying that VirtualHosts xx.xx.xx.xx:80 overlaps with VirtualHosts xx.xx.xx.xx:80.

When I call my only the pops up. It seems like the mapping is wrong.

apachectl -t output:

[warn] VirtualHost xx.xx.xx.xx:80 overlaps with VirtualHost xx.xx.xx.xx:80, the first has   precedence, perhaps you need a NameVirtualHost directive
Syntax OK

apache2ctl -S output:

[Wed Feb 29 02:05:17 2012] [warn] VirtualHost xx.xx.xx.xx:80 overlaps with VirtualHost xx.xx.xx.xx:80, the first has precedence, perhaps you need a NameVirtualHost directive
VirtualHost configuration:*  (/etc/apache2/sites-enabled/
xx.xx.xx.xx:443 (/etc/apache2/ports.conf:12)
xx.xx.xx.xx:80 (/etc/apache2/httpd.conf:3)
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server (/etc/apache2/httpd.conf:11)
     port 80 namevhost (/etc/apache2/httpd.conf:11)
     port 80 namevhost (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost (/etc/apache2/apache2.conf:241)
     port 80 namevhost (/etc/apache2/apache2.conf:249)
Syntax OK

Wordpress is installed through apt-get. I have a symlink in /var/www/ which points to /usr/share/wordpress and activated in /etc/apache2/sites-available and a2ensite.

share|improve this question
can you run apachectl -t and paste any errors you see? – qweet Feb 28 '12 at 10:15
edited post with apachectl -t output. – cherrun Feb 28 '12 at 11:34
up vote 4 down vote accepted

You have a NameVirtualHost directive, but you're not using it. You're specifying the IP address and/or the hostname in your <VirtualHost> declaration - that's not what you want.


<VirtualHost xx.xx.xx.xx:80>



To both be simply:

<VirtualHost *:80>
share|improve this answer
This fixed the error output, when calling apachectl -t, but somehow now the maps to my wordpress install, which lies in www/wordpress, although that's not what I want. Therefore I changed the values back to the IP address. I think something is completely messed up with my settings. – cherrun Feb 28 '12 at 19:10
Where's your wordpress configured? And what output do you get from apache2ctl -S? – Shane Madden Feb 28 '12 at 19:13
edited first post with output. – cherrun Feb 29 '12 at 1:05
@cherrun You have an three total vhosts that are configured to be; the one in your httpd.conf file (which is empty by default in the Debian packaging that you're using) is getting precedence over the ones in apache2.conf and sites-available/default. Get rid of the copies that shouldn't exist, and set all port 80 vhosts to the correct host specification as outlined in my answer. You have vhost definitions sprinkled all over the place: ports.conf, httpd.conf, and apache2.conf, which is making things a lot more complicated than they need to be. – Shane Madden Feb 29 '12 at 1:29
Which one is the correct file to write all the vhosts to? Is it alright that the ports.conf only have the Listen 80 and 443 option without specifying further vhosts? – cherrun Feb 29 '12 at 13:27

You may try next:

  1. Move virtual host declaration to sites-available/firstDomain.
  2. Remove everything from httpd.conf (you may try to define ServerName in apache2.conf)
  3. Ensure that you have sites-available/firstDomain and sites-available/secondDomain symlinked to sites-enabled/firstDomain and sites-enabled/secondDomain respectively.
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.