configuring only subdomain on apache2

0

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

Hrishikesh Kale

Posted 2012-04-27T12:55:42.870

Reputation: 3

Answers

0

  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.

RedGrittyBrick

Posted 2012-04-27T12:55:42.870

Reputation: 70 632