I have a windows XP machine, installed apache at C:\Program Files\Apache Software Foundation\Apache2.2
I set the document root as DocumentRoot "C:/projects" in httpd.conf and my projects are proj1 and proj2 in c:\projects
<VirtualHost *:80>
DocumentRoot "C:/projects/proj1"
ServerName proj1
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/projects/proj2"
ServerName proj2
</VirtualHost>
both proj1 and proj2 have index.php files. I added
开发者_Go百科127.0.0.1 proj1
127.0.0.1 proj2
in the hosts file too.
still, when I type http://proj1, I only see the files listing, the virtual directory isn't working. what am I missing?
Aside from restarting / reloading Apache there's a few other things to check:
First, here are examples of valid vhost configurations:
<VirtualHost *:80>
ServerName proj1
DocumentRoot "c:/www/proj1"
<Directory "c:/www/proj1" >
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName proj2
DocumentRoot "c:/www/proj2"
<Directory "c:/www/proj2" >
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Note how proj1
and proj2
both have their own VirtualHost
directive.
Secondly, make sure the vhosts declarations are being loaded by Apache. In order to get mine to work, I had to uncomment this line in httpd.conf
:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Not quite enough info without seeing all your config files, but here are a couple things to check:
- Any hints in the apache error log when you start it up?
- Make sure you have NameVirtualHost *:80 somewhere in your config files and that statement is loaded before your vhosts.
- If you can see the directory listing of the proj1 dir, then vhosts are working and you can tweak directory permissions and properties (index files, dir listings allowed, etc).
精彩评论