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.

So I have a main domaing pointing to my server (xx.xx.xx.xx).

I tried to create a subdomain with the following virtualhost file.

<VirtualHost myip:80>

    ServerName  sub.mydomain

</VirtualHost>

<VirtualHost myip:80>

    ServerName mydomain.com


</VirtualHost>
  • I didn't put all the other codes here.

I can't even ping sub.mydomain.com. My domain.com works just fine.

Am I doing something wrong here?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You need a valid DNS record for your subdomain too. You can accomplish this by either setting up an individual DNS entry for each new subdomain, or just creating a wildcard entry for *.domain.com that is a CNAME to domain.com. With the whildcard method, you can put whatever.domain.com in your apache config, and they will all just work without any other configuration. But every namebasedvirtualhost has to have a valid DNS entry.

share|improve this answer

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.