I set up virtual hosts on ubuntu 12.04. But not everything is going as it should. I have two files in sites-enabled. One file holds the code for one site, and it works, one for a dozen other sites, and they work also. Except now I try to add another one to the second file, and the site cannot be found. Strangely enough, the first site in that file is also the site that is visible when I go to the ip of my server, skyo.be. The code is always the same:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/skyo/publichtml
ServerName www.skyo.be
Serveralias sky.be
Serveralias www.skyo.be
ErrorLog /var/www/skyo/logs/error.log
Loglevel warn
CustomLog /var/www/skyo/logs/access.log combined
<Directory /var/www/skyo/public
AllowOverride All
Order allow,deny
allow from all


This is the first site in that file, when I put another site above this code, this site is visible on skyo.be. So is the new site I wanted to add. So I can access the site, all the redirections work.

I know this is kind of a mess, I would like to have different files, so for each site one file in sites-available instead of one (strangely enough the second file works). I followed the tutorial on creating virtual hosts:https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts

Does anyone have an idea how to get this fixed?


  • First off, I’ve cleaned up your config:

    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/skyo/publichtml
        ServerName www.skyo.be
        Serveralias sky.be
        ErrorLog /var/www/skyo/logs/be-error.log
        Loglevel warn
        CustomLog /var/www/skyo/logs/access.log combined
        <Directory /var/www/skyo/publichtml>
            AllowOverride All
            Order allow,deny
            allow from all

    You don’t set an alias that points to the ServerName. Also, only have one ServerAlias. They can be set like this:

    ServerName example.com
    ServerAlias www.example.com my.example.com

    Next, run this, and give me the output:

    apache2ctl -S
  • @JonsJava


    I made a mistake in the alias of skyo, that was why it pointed toward that site, I guess. Still no luck with the new site franklefebure.be. It shows on the ip of the server but not on the domainname. Maybe it is a problem with the A records.

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/franklefebure/public_html
    ServerName www.franklefebure.be
    Serveralias franklefebure.be

    ErrorLog /var/www/franklefebure/logs/error.log
    Loglevel warn
    CustomLog /var/www/franklefebure/logs/access.log combined

    <Directory /var/www/franklefebure/public_html>
    AllowOverride All
    Order allow,deny
    allow from all



    [Wed Mar 25 08:50:04 2015] [warn] The Alias directive in /etc/apache2/conf.d/phpmyadmin.conf at line 3 will probably never match because it overlaps an earlier Alias.
    Loaded Modules:
    coremodule (static)
    logconfigmodule (static)
    logiomodule (static)
    mpmpreforkmodule (static)
    httpmodule (static)
    somodule (static)
    aliasmodule (shared)
    authbasicmodule (shared)
    authnfilemodule (shared)
    authzdefaultmodule (shared)
    authzgroupfilemodule (shared)
    authzhostmodule (shared)
    authzusermodule (shared)
    autoindexmodule (shared)
    cgimodule (shared)
    deflatemodule (shared)
    dirmodule (shared)
    envmodule (shared)
    mimemodule (shared)
    negotiationmodule (shared)
    php5module (shared)
    reqtimeoutmodule (shared)
    rewritemodule (shared)
    setenvifmodule (shared)
    status_module (shared)
    Syntax OK

  • I apologize. I meant for you to give me the output for “apache2ctl -S”

  • wildcard NameVirtualHosts and default servers:
    *:80 is a NameVirtualHost
    default server www.franklefebure.be (/etc/apache2/sites-enabled/franklefebure:1)
    port 80 namevhost www.franklefebure.be (/etc/apache2/sites-enabled/franklefebure:1)
    port 80 namevhost www.skyo.be (/etc/apache2/sites-enabled/skyo:1)
    port 80 namevhost www.tcpajottenland.be (/etc/apache2/sites-enabled/skyo:17)
    port 80 namevhost www.generationalbator.be (/etc/apache2/sites-enabled/skyo:37)
    port 80 namevhost www.gorgonmotors.be (/etc/apache2/sites-enabled/skyo:56)
    port 80 namevhost www.lapsuslanguages.be (/etc/apache2/sites-enabled/skyo:75)
    port 80 namevhost www.dance-inn.be (/etc/apache2/sites-enabled/skyo:94)
    port 80 namevhost www.demo.schoolbox.be (/etc/apache2/sites-enabled/skyo:113)
    port 80 namevhost www.demo2.schoolbox.be (/etc/apache2/sites-enabled/skyo:132)
    port 80 namevhost www.fr.melkopschool.be (/etc/apache2/sites-enabled/skyo:151)
    port 80 namevhost www.voka.theantennapub.be (/etc/apache2/sites-enabled/skyo:170)
    port 80 namevhost www.sketchingtheworld.org (/etc/apache2/sites-enabled/skyo:189)
    port 80 namevhost www.pantalone.be (/etc/apache2/sites-enabled/skyo:209)
    port 80 namevhost www.vendiscapital.com (/etc/apache2/sites-enabled/vendiscapital:1)

    as you see I created a different file for franklefebure, which I intend to do for all the sites now.

  • Show 2 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

The vhosts are meant to be in /etc/apache2/sites-available not sites-enabled. Once you’ve created your vhost in sites-available you need to then run a2ensite and choose the config you want to enable which will create a link in sites-enabled.