Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have added sub.example.com as a new A record in my DNS manager, and created the virtual host file:

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    ServerName sub.example.com
    ServerAlias sub.example.com
    DocumentRoot /srv/www/sub.example.com/public_html/
    ErrorLog /srv/www/sub.example.com/logs/error.log
    CustomLog /srv/www/sub.example.com/logs/access.log combined

At the moment the page just shows the Apache "It Works".

The main site example.com is working with this virtual host:

<VirtualHost *:80>
     ServerAdmin webmaster@example.com
     ServerName example.com
     ServerAlias www.example.com
     DocumentRoot /srv/www/example.com/public_html/
     ErrorLog /srv/www/example.com/logs/error.log
     CustomLog /srv/www/example.com/logs/access.log combined

Why does sub.example.com not get picked up?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You have to make an addition at the top :

NameVirtualHost   x.x.x.x:80

where the x.x.x.x is your ip address.

Also, keep in mind that you need to restart your apache, and make sure that your DNS is properly resolving.

share|improve this answer
Thanks! It was the IP address that I needed to add. Why would the * not work? I thought that was a wildcard for the IP? –  xylar Jan 28 '13 at 10:25

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.