Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 running an AWS setup that currently consists of an ELB pointing to a single EC2 instance. The instance is running Ubuntu 12.04.2 and Apache 2.22.2. I've setup several subdomains on the server in the past. I'm trying to set another one up today, but I'm beating my head against the wall trying to figure out what I missed. I'm sure it's some little step that I've overlooked or gotten not-quite-right.

My DNS records are setup using Route 53. I logged in to the AWS console and added a new CNAME record for my server. We'll call it It looks like this: 3600    IN  CNAME

That seems to be working just fine, as pointing my browser to brings up the default VirtualHost.

So, all I have left to do now is create another VirtualHost config file, right?

mkdir /http/www/
touch /httpd/www/
cd /etc/apache2/sites-available
sudo cp
sudo sed -i 's/'
cd ../sites-enabled
sudo ln -s ../sites-available/
sudo apachectl restart

That should be it, right? But when I point my browser to, it's still pointing to the default VirtualHost. What step am I skipping?


<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /httpd/www/
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    <Directory /httpd/www/>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            allow from all

    ErrorLog /var/log/apache2/

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

    CustomLog /var/log/apache2/ combined


Per the request in the comments:

sudo apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server (/etc/apache2/sites-enabled/
         port 80 namevhost (/etc/apache2/sites-enabled/
         port 80 namevhost (/etc/apache2/sites-enabled/
         port 80 namevhost (/etc/apache2/sites-enabled/
         port 80 namevhost (/etc/apache2/sites-enabled/
         port 80 namevhost (/etc/apache2/sites-enabled/
         port 80 namevhost (/etc/apache2/sites-enabled/
         port 80 namevhost (/etc/apache2/sites-enabled/
Syntax OK

The output of this is a bit puzzling to me. I would expect the default to be rather than The configuration file for has ServerAlias * defined in it.

share|improve this question
Check apache2ctl -S, also for ubuntu there are the helpers a2ensite a2dissite tools for managing enabled and available links. and can somewhat simplify working with Apache2 on Ubuntu. – David Jun 18 '13 at 20:19
a, b, c, D, and then E. To enforce ordering, prefix with numbers for priority as Apache's include directive works Alphanum sort ordered in a EXT based filesystem. ( Apache, not ubuntu re: include directive ) – David Jun 18 '13 at 20:36
up vote 2 down vote accepted

It's possible that your vhost configuration file is not being seen by apache, either for lack of an include directive, or a lack of permissions.

Ensure that in your main configuration file you have a directive like

Include /etc/apache2/sites-enabled/*

If it is in a conditional block, such as <IfDefine VHOSTS>, ensure the condition is evaluating to true (eg. by ensuring the correct define is specified or the correct module is loaded).

Also, ensure that whichever user apache is running as (usually apache) has permission to read the file and enumerate the sites-enabled directory. Specifically, it needs read and execute on the sites-enabled directory, and read on all the configuration files in sites-enabled.

Per your edit, it is probable that the ServerAlias * directive you have is confusing things. This is not the way to designate a default vhost. The default vhost, with name-based virtual hosting, is used only when no other virtual host matches (ServerAlias or ServerName), and is simply the first one that is loaded, in alphabetical order. This is how the host was most likely chosen. To overcome this, usually the intended virtual host configuration file is named something like 00_default_vhost.conf.

Matching is also done in the order files are read. So, any sites that aren't or will be matched by with the wildcard alias.

share|improve this answer
On the last line of my apache2.conf file, I have Include sites-enabled/. It is not in a conditional block. All of the other subdomains are working fine. Apache is running as www-data and has read access to all of the configuration files and site directories. – Ben Harold Jun 18 '13 at 20:32
What is the correct way to designate a default host? – Ben Harold Jun 18 '13 at 20:33
I'll edit again and explain. – Falcon Momot Jun 18 '13 at 20:36
The first defined Virtual Host will be the default. Since you're using include, I believe that will be based on the alphabetical filename. Hence beating out – Christopher Karel Jun 18 '13 at 20:38
@BenHarold plus my comment will get you on track with specifying which is the default – David Jun 18 '13 at 20:39

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.