php 通过 WAMP 阻止的所有本地主机页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6296007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:55:53  来源:igfitidea点击:

All localhost pages via WAMP blocked?

phphtmlwampfirewallwindows-firewall

提问by tnw

I've been trying to fix a weird 403 Forbidden error I get when I try to go to one of my pages via WAMP on the localhost.

我一直在尝试修复一个奇怪的 403 Forbidden 错误,当我尝试通过本地主机上的 WAMP 转到我的一个页面时。

After adding a rule to open up port 80 via Windows Firewall, which apache uses, I notice that this does NOT fix my problem and instead gives me a 403 forbidden for ALL my pages via localhost.

在添加了通过 apache 使用的 Windows 防火墙打开端口 80 的规则后,我注意到这不能解决我的问题,而是通过 localhost 为我的所有页面提供了 403 禁止。

Removing the rule I just made (which caused this to begin with) does not fix it. Disabling Windows Firewall does not fix it. Restarting my computer does not fix it. Any ideas?

删除我刚刚制定的规则(导致此问题开始)并不能解决问题。禁用 Windows 防火墙并不能修复它。重新启动我的计算机并不能修复它。有任何想法吗?

EDIT2: I AM able to go to localhost/phpmyadmin for whatever that's worth.

EDIT2:我可以去 localhost/phpmyadmin 获取任何有价值的东西。

EDIT3: The contents of my httpd.conf: http://www.mediafire.com/?p54a53443efkefs

EDIT3:我的 httpd.conf 的内容:http: //www.mediafire.com/?p54a53443efkefs

回答by Sean Walsh

In httpd.conf, find the following sections and ensure they are correct:

在 httpd.conf 中,找到以下部分并确保它们是正确的:

DocumentRoot "C:/wamp/www"

DocumentRoot "C:/wamp/www"

<Directory />
    Options None
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory C:/wamp/www>
    Options None
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Those are the settings that I am using in my install and they work fine. Make sure you restart Apache if you make any changes.

这些是我在安装中使用的设置,它们工作正常。如果进行任何更改,请确保重新启动 Apache。

If you continue having issues, please update your original question with your httpd.conf.

如果您仍然遇到问题,请使用您的 httpd.conf 更新您的原始问题。



Edit:

编辑:

This is kludgey and I'm just grasping at straws here, but try adding a new entry to your vhosts:

这很麻烦,我只是在这里抓住了稻草,但请尝试向您的虚拟主机添加一个新条目:

<VirtualHost *:80>
    DocumentRoot "C:/wamp/www"
    ServerName localhost
</VirtualHost>

回答by Tama

It can be an ipv6 issue. So in your httpd.conf add your ipv6 local address:

这可能是一个 ipv6 问题。所以在你的 httpd.conf 中添加你的 ipv6 本地地址:

Change:

改变:

Allow from 127.0.0.1

to:

到:

Allow from 127.0.0.1
Allow from ::1:

回答by Anirudh Ramanathan

Try changing the line in httpd.conf

尝试更改 httpd.conf 中的行

Allow from 127.0.0.1 

or

或者

 Allow from all

Refer to the documentation

参考文档

回答by Dave

Marco Tamanti solution worked for me:

Marco Tamanti 解决方案对我有用:

Allow from 127.0.0.1
Allow from ::1:

so I have:

所以我有:

<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1:
</Directory>

回答by Ryre

Your "Deny From All" is what's causing the 403 error. The setup you post is used to prevent all traffic, with the intention of later allowing specific traffic. If you never allow specific traffic, you'll never get it to work.

您的“拒绝所有人”是导致 403 错误的原因。您发布的设置用于阻止所有流量,目的是稍后允许特定流量。如果您从不允许特定流量,您将永远无法使用它。

With your 404 error, ensure you're using the right path and there's no errors in your apache error log.

对于 404 错误,请确保使用正确的路径,并且 apache 错误日志中没有错误。

http://httpd.apache.org/docs/current/mod/core.html#directory

http://httpd.apache.org/docs/current/mod/core.html#directory

回答by Hassan Saeed

you require 3 steps please ensure these 3 things

您需要 3 个步骤,请确保这 3 件事

1.

1.

first of all Port 80 and 443 must be allow for both TCP and UDP packets. To do this, create 2 inbound rules for TPC and UDP on Windows Firewall for port 80 and 443. (or you can disable your whole firewall for testing but permanent solution if allow inbound rule)

首先端口 80 和 443 必须允许 TCP 和 UDP 数据包。为此,请在 Windows 防火墙上为端口 80 和 443 为 TPC 和 UDP 创建 2 个入站规则。(或者您可以禁用整个防火墙进行测试,但如果允许入站规则,则为永久解决方案)

2.

2.

If you are using WAMPServer 3 See bottom of answer

如果您使用的是 WAMPServer 3 请参阅答案底部

For WAMPServer versions <= 2.5

对于 WAMPServer 版本 <= 2.5

You need to change the security setting on Apache to allow access from anywhere else, so edit your httpd.conffile.

您需要更改 Apache 上的安全设置以允许从其他任何地方访问,因此请编辑您的httpd.conf文件。

Change this section from :

将此部分更改为:

#   onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost

To :

到 :

#   onlineoffline tag - don't remove
    Order Allow,Deny
      Allow from all

if "Allow from all" line not work for your then use "Require all granted" then it will work for you.

如果“全部允许”行对您不起作用,则使用“要求全部授予”,那么它对您有用。

WAMPServer 3 has a different method

WAMPServer 3 有不同的方法

In version 3 and > of WAMPServer there is a Virtual Hosts pre defined for localhostso dont amend the httpd.conffile at all, leave it as you found it.

在 WAMPServer 的版本 3 和 > 中,有一个预定义的虚拟主机,localhost因此根本不要修改httpd.conf文件,将其保留原样。

Using the menus, edit the httpd-vhosts.conffile.

使用菜单编辑httpd-vhosts.conf文件。

enter image description here

在此处输入图片说明

It should look like this :

它应该是这样的:

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot D:/wamp/www
    <Directory  "D:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

Amend it to

修改为

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot D:/wamp/www
    <Directory  "D:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Hopefully you will have created a Virtual Host for your project and not be using the wamp\wwwfolder for your site. In that case leave the localhost definition alone and make the change only to your Virtual Host.

希望您已经为您的项目创建了一个虚拟主机,而不是wamp\www为您的站点使用该文件夹。在这种情况下,不要管本地主机定义,只对您的虚拟主机进行更改。

3.Dont forget to restart All Services of Wamp or Apache after making this change

3.更改后不要忘记重新启动 Wamp 或 Apache 的所有服务

回答by elmizan

Simple solutions. Just Run as Administrator the Wamp Installations file and they will works like a charm :)

简单的解决方案。只需以管理员身份运行 Wamp 安装文件,它们就会像魅力一样工作:)

回答by Gadgetchimp

What I found worked for me after starting WAMP was, left clicking the WAMP icon that appears on the Taskbar, then clicking Start All Services under the Quick Admin. I was then able to access localhost using IE. I even went back to the httpd.config file and set it back to it's defaults.

启动 WAMP 后,我发现对我有用的是,左键单击任务栏上出现的 WAMP 图标,然后单击快速管理下的启动所有服务。然后我就可以使用 IE 访问 localhost。我什至回到 httpd.config 文件并将其设置回它的默认值。

Hope this helps.

希望这可以帮助。