无法使用 wamp 和 Chrome 访问本地主机

Can't access localhost with wamp and Chrome

从今天开始,当我在启动 WAMP 后转到本地主机 (http://localhost) 时,在 Firefox 中,像往常一样,一切正常,但是 Chrome 说 "Forbidden, You don't have permission to access / on this server."

有人可以帮助我吗?

我也是这样。从今天开始,我无法使用 http://localhost 访问我的 wamp 文件 chrome。

在 Firefox 或 Explorer 中我没有问题。

问题解决后可以使用127.0.0.1

编辑:帮我解决了。

这是一个 IPv6 问题。 Google 必须刚刚更新 Chrome.

首先确保您的主机文件中有以下行并且没有注释。

::1 localhost

接下来,打开您的 Apache 配置 (httpd.conf) 并将以下内容添加到侦听部分:

Listen [::1]:80

接下来,您需要编辑 httpd.conf 中的目录语句或您的虚拟主机文件。他们可能看起来像这样。

<Directory "C:\path">
    Options Indexes FollowSymLinks
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
    AllowOverride All
</Directory>

在 'Allow from 127.0.0.1' 之后添加一行,看起来像这样

<Directory "C:\path">
    Options Indexes FollowSymLinks
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
    Allow from ::1
    AllowOverride All
</Directory>

对于任何 运行 遇到这个问题的人来说,这就是我在 apache 2.4.17 上的工作方式

  • 主机文件在这里:C:\Windows\System32\drivers\etc

  • httpd.conf 在这里:C:\wamp64\bin\apache\apache2.4.17\conf

  • httpd-vhosts.conf 在这里:C:\wamp64\bin\apache\apache2.4.17\conf\extra

我确保在我的主机文件中启用了本地主机:

127.0.0.1       localhost
::1             localhost

只需删除行首的#。

确保在您的 httpd.conf

中取消注释此行
Include conf/extra/httpd-vhosts.conf

在我的文件中是第 518 行。

然后将其添加到您的 httpd-vhosts.conf 文件中:

<VirtualHost *:80>
    ServerAdmin somerandomdude@whaaat.com
    DocumentRoot "c:/wamp64/www"
    ServerName localhost
</VirtualHost>

然后重启WAMP。

我不知道这是否是最干净的方法(很可能不是)。但对我来说效果很好。

我遇到了同样的问题。我就是这样解决的:

  • 我首先将 ::1 添加到主机文件,通常在 C:\Windows\System32\drivers\etc
  • 中找到
  • 然后我继续打开我的 Chrome 浏览器。我去设置>高级设置>打开代理设置(标题系统下)
  • 在弹出的新 window 中转到 'LAN settings' 然后确保选中 'Automatically detect settings'