Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have the grasp of setting up multiple name-based domains on Apache 2 using virtual hosts. Say I have a domain name called 'domain.com'. I now want to set up a sub domain of this, like 'demo.domain.com' and want this to go to a different folder on Apache to serve up a different website.

How would I set this up exactly? Do I need to set up a CNAME and then a virtual host in Apache? Or do I just setup a ServerAlias in Apache? I'm a little confused.

I'm using Slicehost for my hosting and DNS, if that helps. Using Ubuntu Hardy with Apache 2.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

The DNS and the server configuration are two different things. For the DNS you will either need a CNAME or an A record for your new subdomain so that it will resolve to the correct IP. The difference is that CNAMEs resolve to other hostnames while A records resolve to IPs. For example:

subdomain.example.com CNAME -> example.com

subdomain.example.com A -> 1.2.3.4

Once the DNS is configured correctly you will then need to configure an Apache virtual host for the new subdomain. Check the documentation here:

http://httpd.apache.org/docs/2.0/vhosts/examples.html

share|improve this answer
    
Thank you. I wasn't too clear on the differences between CNAME and A records. Also, I still thought it wasn't working, but all I had to do was wait for it to propagate. Have a good day Dave. –  littlejim84 Jan 16 '10 at 12:27
add comment

Your Answer

 
discard

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.