我希望Apache在我的Windows本地计算机上提供来自
c:/Apache24/htdocs和
d:/wwwresp的文档。在httpd-vhosts.conf中我尝试:
<VirtualHost *:80>
DocumentRoot "c:/Apache24/htdocs"
ServerName test.localhost
Options Indexes FollowSymLinks
<Directory "D:/www">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
和主持人
127.0.0.1 test.localhost
但浏览到http://test.localhost会导致显示
C:/htdocs下的目录列表?
我是否接近这个:
Alias c:/Apache24/htdocs D:/www
<Directory c:/Apache24/htdocs>
Require all granted
</Directory>
如果是这样,我在哪里添加它?注:我想存储和提供来自D:/的Web文档,因为C:/现在变得相当充实。
答案 0 :(得分:1)
检查您的虚拟主机之前是否有行NameVirtualHost *:80
。那应该已经存在了,但要检查一下。
将您的主机更改为指向一个文件夹,例如:
<VirtualHost *:80>
DocumentRoot "D:/www"
ServerName localserver
Options Indexes FollowSymLinks
<Directory "D:/www">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
创建从c:/Apache24/htdocs
到例如D:/www/apache
文件夹的符号链接。
然后,您可以从网址
c:/Apache24/htdocs
文件夹
localserver/apache
阅读有关符号链接的更多信息: http://en.wikipedia.org/wiki/NTFS_symbolic_link
另一种选择是创建两个URL(域)和虚拟主机(如上面添加):
<VirtualHost *:80>
DocumentRoot "c:/Apache24/htdocs"
ServerName other.localserver
Options Indexes FollowSymLinks
<Directory "c:/Apache24/htdocs">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
并在您的主持人中:
127.0.0.1 localserver other.localserver
答案 1 :(得分:0)
在Windows 7上安装了WAMP
C:\Apache24并提供
C:\Apache24\htdocs之外的文档,您可能希望从D驱动器提供文档,因为C已满。转到:
C:\Apache24\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:/www/apache/site1"
ServerName site1.dev
<Directory "D:/www/apache/site1">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/www/apache/site2"
ServerName site2.dev
<Directory "D:/www/apache/site2">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
并修改:
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 site1.dev
127.0.0.1 site2.dev
您现在应该能够(本地)提供来自
D:\www\apache的网络文档而无需sym链接。