突然之间,我的本地WampServer vhost不能工作了。
我已经在vhosts.conf和hosts中添加了一个新的vhost。
当我在web浏览器中加载该虚拟主机时,我收到403 Forbidden。
在vhosts.conf中,我有:
<VirtualHost *:80>
ServerName example.com.au
ServerAlias example.com.au
DocumentRoot "D:\Dropbox\WAMP\WWW\example.com.au"
<Directory "D:\Dropbox\WAMP\WWW\example.com.au">
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
</VirtualHost>在httpd.conf中,我有:
Listen 10.0.0.199:80 ::1
Listen [::0]:80
<Directory />
AllowOverride none
Require all denied
</Directory>其中10.0.0.199是我PC的IP。
WampServer已联机。
WampServer 3.0.6 Apache2.4.23
感谢你的帮助。
发布于 2018-02-02 19:10:41
我变了
<Directory />
AllowOverride none
Require all denied
</Directory>至
<Directory />
AllowOverride none
Require all granted
</Directory>在httpd.conf中,这解决了403错误。
发布于 2018-02-02 21:46:19
httpd.conf中的缺省配置包含您需要的所有监听参数
Listen 0.0.0.0:80
Listen [::0]:80这表示侦听端口80,无论这台PC的ip地址是IPV4还是IPV6地址范围,这都是您所需要的。
httpd.conf的这一部分也应该保留为您找到的位置。这设置了对安装WAMPServer(Apache)的驱动器(Apache)上所有文件夹的所有权限的基本拒绝,并且应该这样做。把它改回这个
<Directory />
AllowOverride none
Require all denied
</Directory>这是为了你的安全着想。它说没有人被允许访问这个驱动程序的根目录,因此不能访问根目录下的任何内容。设置完成后,您应该只打开Apache实际需要访问的内容。这就是您在httpd-vhosts.conf文件中对该站点也需要访问的文件夹所做的操作。如果你被黑客攻击了,那么黑客只能访问那些拥有访问权限的文件夹,而不能访问整个驱动器。
您在httpd-vhosts.conf中的虚拟主机定义应该如下所示
<VirtualHost *:80>
ServerName example.com.au
ServerAlias www.example.com.au
DocumentRoot D:/Dropbox/WAMP/WWW/example.com.au
<Directory "D:/Dropbox/WAMP/WWW/example.com.au/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
## Dangerous unless you really mean to
## allow the universe into your server
## I would use one of the other options and comment this one out
Require all granted
# If access from this PC only then us
# i.e. you are a standalone developer
# uncomment this
#Require local
#If access from your local network is required
# i.e. you are working with other devs within your local network
# uncomment this
#Require ip 10.0.0
</Directory>
</VirtualHost>注意到Unix使用了正斜杠,而
<Directory....标记需要一个尾随斜杠
然后检查您的HOSTS文件,它应该是这样的
127.0.0.1 localhost
::1 localhost
127.0.0.1 example.com.au
::1 example.com.auhttps://stackoverflow.com/questions/48581403
复制相似问题