Aug 9, 2011

Trying to create subdomain with Apache2


I’m using Ubuntu 10.04 and Apache2.2 on a Linode VPS – I’m trying to create a subdomain of I’ve added this entry to /etc/apache2/sites-enabled:

<VirtualHost *:80>
     DocumentRoot /srv/www/
     ErrorLog /srv/www/
     CustomLog /srv/www/ combined

and this line to /etc/hosts:

and created a DNS zone file pointing to…

I can successfully ping but can’t get index.html to load in my browser…

Any ideas?


Since you’re using virtual hosts, make sure to put this subdomain container BEFORE your main virtual host container. What ever comes first trumps whatever comes after, so if your file looks like this, it won’t work:

<virtualHost *:80>
 ServerAlias *
 DocumentRoot /srv/www/
</virtualHost><VirtualHost *:80>
 DocumentRoot /srv/www/

Make sense? You have to flip them, so that the 2nd VirtualHost container in my example is first. If that’s not the problem, and you’ve already done this, then check the Apache error log (actually, that should be your first step, regardless).

Also, make sure file permissions are correct.

Related posts:

  1. Apache2 subdomain serve up the same conent
  2. Subdomain not being recognised in sites-available
  3. Apache VHost Configuration Precedence?
  4. apache virtual hosts – server not found for subdomain
  5. Apache2 dynamic documentroot depending on URL

Leave a comment