【问题标题】:Can't access 127.0.0.1 apache 2 (MacOS X)无法访问 127.0.0.1 apache 2 (MacOS X)
【发布时间】:2016-03-21 22:48:33
【问题描述】:

在我的 MacBook Pro mid2009 更新到 MacOS X El Capitan 之后,我发现很多东西不再像以前那样工作了。 内置 apache2 在 http://127.0.0.1 上不可用,但在 http://localhost 上可用。在优胜美地,他们俩都正常工作。

/private/etc/hosts 看起来像这样:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1    localhost

看起来很奇怪,因为 127.0.0.1 和 localhost 是同一个东西。 知道发生了什么吗?

httpd.conf

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

【问题讨论】:

  • 看来httpd 绑定到::1not 127.0.0.1。当您使用 localhost 时,您通过 IPv6 地址进行连接,请edit 将您的问题添加到您的 apache 配置中,以及可能在 statup / binding 上生成的任何错误日志输出。跨度>
  • httpd.conf 已添加。

标签: macos apache apache2 localhost


【解决方案1】:

在您的 httpd.conf 中,您将有一个 Listen 指令,这将是服务器将绑定到的 IP 地址/端口。

在你定义的 conf 文件中

Listen 80

也就是说,你应该绑定到端口 80 上的所有接口,这将包括 IPv4 和 IPv6;

禁用 IPv6 应该会,将此行更改为

# allow access on all interfaces
Listen 0.0.0.0:80

# or for local access only
# Listen 127.0.0.1:80

# or more specifically
# Listen 192.168.0.0:80
# To listen on a specific subnet

要弄清楚为什么通过 IPv6 访问网站时无法加载,需要额外的错误/调试日志。

【讨论】:

  • 我尝试更改Listen 很多次。没有效果。 Apache 的错误日志只包含 .htaccess 中的错误。
猜你喜欢
  • 2016-04-05
  • 2021-10-20
  • 1970-01-01
  • 2018-02-23
  • 1970-01-01
  • 1970-01-01
  • 2012-01-31
  • 1970-01-01
  • 2017-09-08
相关资源
最近更新 更多