0

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

Laqua
  • 1

2 Answers2

1

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:/

Mike
  • 802
  • 4
  • 5
0

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).

Kenny Rasschaert
  • 9,045
  • 3
  • 42
  • 58
  • 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