Super User is a question and answer site for computer enthusiasts and power users. 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 have a domain and subdomains on a server say example.com and api.example.com We want to add another server to our application cdn.example.com which is a different physical server. So i'm trying to configure subdomain cdn.example.com I've mapped the ip of new server to subdomain cdn.example.com

when i ping cdn.example.com its returning correct ip. But when i put this url in browsers its now showing page in the subdomain directory.

I've create virtual host in /etc/apache2/sites-enabled/cdn.example.com

when i try to open site using ip its showing the pages in default directory /var/www/index.html

i;ve mapped the cdn.example.com to folder /srv/www/cdn.example.com/public_html

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

this is my cdn.example.com file in sites-enabled directory

I have two questions: 1. is it necessary to configure main domain before configuring subdomain? 2. can we configure only subdomain on server?

PS: I have debian 6.0.3 on my new server

share|improve this question
up vote 0 down vote accepted
  1. is it necessary to configure main domain before configuring subdomain?

No.

A useful point is that the first defined site is the one that is served if the client request is for a site domain name or address not in the Apache configuration explicitly.

  1. can we configure only subdomain on server?

Yes.

You'll need to arrange in DNS that the subdomain's address records point to the appropriate web-server.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .