I've rented a small virtual private server that runs Ubuntu, and I'm trying to configure a sub-domain. Thanks to several resources I've figured out how I'm supposed to do this, but still it does not work at all.

Hopefully someone can help me find out what I've done wrong.

I've created a file called <domain>.conf in /etc/apache2/sites-available. It contains the following:

NameVirtualHost *:80

# Configuration for index.<domain> and <domain>.
<VirtualHost *:80>
        ServerAdmin administrator@<domain>
        DocumentRoot /var/www/sites/<domain>/index

        ServerName index.<domain>
        ServerAlias <domain>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

I've enabled the website using following command:

sudo a2ensite /etc/apache2/sites-available/<domain>.conf

Furthermore I've configured the DNS settings as following:

Name            Type            Value         
<domain>        A               <ip-address>
index.|DOMAIN|  A               <ip-address>

Opening http://<domain> works perfectly fine but opening http://index.<domain> does not. Instead I get a message telling me that "This web page is not available".

apache2ctl -S returns the following:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message

VirtualHost configuration:
    *:80 is a NameVirtualHost
        default server localhost (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost index.<domain> (/etc/apache2/sites-enabled/<domain>.conf:4)
        alias <domain>
  • 5
    You need to figure out if it's a DNS or Apache problem first. Does dig index.example.com return the correct IP?
    – faker
    Mar 25, 2015 at 9:15
  • If you've confirmed that it's not a DNS issue, you should next check the log files that you've configured for the virtual host. Mar 25, 2015 at 9:43
  • 1
    apache2ctl -S should show what apache's idea of the virtualhosts is.
    – wurtel
    Mar 25, 2015 at 11:11
  • @faker No it doesn't. The header contains a NXDOMAIN status and 0 answers, but I do not know what this means. This is what the authority section looks like: <domain>. 10800 IN SOA <nameserver>. hostmaster.<domain>. 2015022700 14400 3600 1209600 86400 Mar 25, 2015 at 16:02
  • 1
    It's really hard to help you here. DNS zone files have a very specific syntax. A trailing dot can change the meaning of the line completely. With your obscurification it's pretty much impossible to tell you what is wrong.
    – faker
    Mar 25, 2015 at 17:37

1 Answer 1


You set a subdomain named "www.domain" and you added a record for the subdomain "index.domain"

Try this:

In your vhost configuration:

<VirtualHost *:80>
    ServerAdmin administrator@domain
    DocumentRoot /var/www/sites/domain/www

    ServerName domain
    ServerAlias www.domain

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

And then run :

apache2ctl -t
service apache2 reload

In your zone file:

domain.     IN    A               W.X.Y.Z
www         IN    CNAME           domain.

And then run :

named-checkzone domain /path/to/zone/file/db.domain
service bind9 reload

Make sure your subdomain is resolved by your DNS server:

dig @W.X.Y.Z www.domain A +short

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.