Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a fresh install of Apache on a Windows Server 2003 box. The root site (e.g. www.mycompany.com) works. I have a subdomain set up that points to a different directory (subdomain.mycompany.com) and I get a "Cannot find server" error when I try to access it.

Here's my httpd.conf file:

<VirtualHost>
    DocumentRoot H:\Websites\"
    ServerName www.mycompany.com
    ServerAlias mycompany.com
    CustomLog logs/mycompany.com.log combined
    ErrorLog logs/mycompany.com.error.log
</VirtualHost>

<VirtualHost>
    DocumentRoot "H:\Websites\subdomain"
    ServerName subdomain.mycompany.com
    CustomLog logs/subdomain.mycompany.com.log combined
    ErrorLog logs/subdomain.mycompany.com.error.log
</VirtualHost>

Like I said the root site works, but the subdomain isn't even being found. This is how things are supposed to be set up, no? I'm really confused on this - I'm used to IIS where I can just right-click and add a site and have everything "Just Work".

share|improve this question

5 Answers 5

up vote 5 down vote accepted

did you put a subdomain record in your dns server?

share|improve this answer
    
Hmm, I had one of my other guys set up the server transfer, so maybe he forgot to do that. Duh! I'll check with him. –  Wayne M Jul 7 '09 at 14:06

You're missing an open-quote on line 2, befor H:\ ...

share|improve this answer

Not sure if this will help but here is an example of two hosts on a simple setup, I have defined that apaches listens for traffic on standard port 80 then each virtual host has the same.

Listen 80

NameVirtualHost *:80

# Site 1 Comment
<VirtualHost *:80>
   ServerName site1.intranet
   ServerAdmin administrator@whatever.com
   DocumentRoot /var/www/html/site1
</VirtualHost>

#  Site 2 Comment
<VirtualHost *:80>
  ServerName site2.intranet
  ServerAdmin administrator@whatever.com
  DocumentRoot /var/www/html/site2
</VirtualHost>

The dns server will take the request site1.intranet or site2.intranet and forward to the same ip, in this case the apache server, the apache config above will redirect to the right folder depending on which site is requested

hope that helps

share|improve this answer

As others have suggested there appears to be a problem with your quotes surrounding the DocumentRoot settings.

As well make sure you have NameVirtualHost *:80 in your configuration so that Apache knows that it is doing Name-based virtual hosting rather than IP-based virtual hosting.

share|improve this answer
    
VirtualHost is for IP-based virtual hosting. NameVirtualHost is for name based virtual hosting which is what you are trying to do here. This is your biggest problem. –  Catherine MacInnes Jul 7 '09 at 14:48
    
If you check out httpd.apache.org/docs/2.2/vhosts you will see that the "NameVirtualHost" declaration is used with named-based configurations not IP-based... You still have to have a "<VirtualHost>" declaration block regardless of IP- or named-based virtual hosting to define the virtual host. –  Jeremy Bouse Jul 7 '09 at 16:25

First check if subdomain.mycompany.com is pointing to the Web Server's IP address. I think this is not working properly and that's why you are getting the "Cannot find server" error.

Regards.

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.