简体   繁体   English

WampServer:403禁止

[英]WampServer: 403 Forbidden

All of a sudden my local WampServer vhosts are not working. 我的本地WampServer虚拟主机突然无法正常工作。

I've added a new vhost to vhosts.conf and hosts . 我在vhosts.confhosts添加了一个新的vhost。

When I load that vhost in a web browser, I receive 403 Forbidden . 当我在网络浏览器中加载该虚拟主机时,收到403 Forbidden

In vhosts.conf , I have: 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>

In httpd.conf I have: httpd.conf我有:

Listen 10.0.0.199:80 ::1
Listen [::0]:80

<Directory />
    AllowOverride none
    Require all denied
</Directory>

where 10.0.0.199 is my PC's IP. 其中10.0.0.199是我的PC的IP。

WampServer is online. WampServer在线。

WampServer 3.0.6 Apache 2.4.23 WampServer 3.0.6 Apache 2.4.23

Help appreciated. 帮助表示赞赏。

I changed 我变了

<Directory />
    AllowOverride none
    Require all denied
</Directory>

to

<Directory />
    AllowOverride none
    Require all granted
</Directory>

in httpd.conf , and that resolved the 403 error. httpd.conf ,解决了403错误。

The default config in httpd.conf has all the Listen parameters you need httpd.conf的默认配置具有您需要的所有Listen参数

Listen 0.0.0.0:80
Listen [::0]:80

This says listen on port 80 of whatever this PC's ip address is for both IPV4 and IPV6 address ranges, and is all you need. 这就是说,侦听此PC的IP地址是IPV4和IPV6地址范围的端口80,这就是您所需要的。

This section of httpd.conf should also be left as you found it. 找到后,也应该保留httpd.conf这一部分。 This sets up the basic denial of all rights to all folders on the drive where you installed WAMPServer(Apache) and should do exactly that. 这将设置对安装WAMPServer(Apache)的驱动器上所有文件夹的所有权限的基本拒绝权限,并且应该做到这一点。 Change it back to this 改回这个

<Directory />
    AllowOverride none
    Require all denied
</Directory>

This is for your security. 这是为了您的安全。 It say nobody is allowed access to the root of this driver and therefore no access to anything below the root. 它说不允许任何人访问该驱动程序的根目录,因此不允许访问根目录下的任何内容。 Once this is set you are then supposed to open up access to ONLY what Apache actually need access to. 设置好之后,就应该只开放对Apache实际需要访问的内容的访问。 That is what you do in your httpd-vhosts.conf file for only the folders that site requires access too. 这就是您在httpd-vhosts.conf文件中仅对站点也需要访问的文件夹进行的操作。 If you are hacked, then a hacker can only access those folder given access and NOT YOUR WHOLE DRIVE. 如果您被黑客入侵,则黑客只能访问被授予访问权限的那些文件夹,而不能访问您的整个驱动器。

Your Virtual Host definition in httpd-vhosts.conf shoudl look like this 您在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>

Note the use of Unix forward slashes and the <Directory.... tag needs a trailing slash 请注意,使用Unix正斜杠,而<Directory....标记则需要末尾斜杠

Then check your HOSTS file it should be like this 然后检查您的HOSTS文件,它应该像这样

127.0.0.1 localhost
::1 localhost
127.0.0.1 example.com.au
::1 example.com.au

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM