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'm running Apache 2.28 on Windows 7, and this is my directory structure:

C:/

www (which contains the Apache server, it's the free Web-Developer Server-Suite, that's its default configuration of C:/www/)

vhosts

vhosts.1

vhosts.2

and I added to httpd-vhosts.conf:

    <Directory C:/www/vhosts.1>   
  Order Deny,Allow   
Allow from all 
</Directory>
   <Directory C:/www/vhosts.2>   
Order Deny,Allow   
Allow from all 
</Directory>

but just to test that I could put them anywhere, I then added a virtualhost, added the domain to the HOSTS file, and put it in C:/www (the main webroot).

This was for the latest domain I added:

<VirtualHost *:80>
    ServerName  testing-server-win7.co.uk
              ServerAlias  www.testing-server-win7.co.uk
    DocumentRoot /www/testing-server-win7.co.uk
    ErrorLog /www/Apache22/logs/error.log

<Directory "/www/testing-server-win7.co.uk">
    Options All
    AllowOverride All
    order allow,deny
    allow from all
</Directory>

and it worked, surprisingly.

Why is this, and can you really place them anywhere on Apache?

This is a development server, btw, not open to the Internet - although the computer does have Internet access.

Anyone tried this here, and did it work for them?

Thanks

share|improve this question

2 Answers 2

I'm going to guess that you need to change the direction of the slashes you are using for c: - it should be C:\ instead of what you have C:/

share|improve this answer
    
It's in C:\, I just mistyped the slashes. –  Laqua Mar 17 '11 at 20:40

The HTTP protocol has a header field called Host. This is what makes virtual hosts possible.

Your browser tries to reach testing-server-win7.co.uk, which your hosts file translates to the appropriate ip.
Aside from sending the HTTP GET request to that ip, it also sends the hostname (by using the Host header field), which seems redundant at first, "Surely the server knows his own name".

Apache can read this and figure out which site you are trying to reach. Then it serves that site to you.


From the documentation:

The <Directory> and <Files> directives, along with their regex counterparts, apply directives to parts of the filesystem. Directives enclosed in a <Directory> section apply to the named filesystem directory and all subdirectories of that directory.

In other words, if you reference a directory of your filesystem with a <Directory> tag in the config file, Apache can serve stuff from it. All you have to do is make it a document root for a virtual host (as you have).

share|improve this answer
    
I get that, but was unsure if the direction of the slash mattered. So basically, the directory location doesn't matter then? –  Laqua Mar 17 '11 at 20:44
    
Ah, missed that part. As long as it is in the web root, or another directory that is referenced by an apache config file, sure. –  Kenny Rasschaert Mar 17 '11 at 20:47

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.