无法访问127.0.0.1 apache 2(MacOS X)

时间:2015-12-15 23:09:39

标签: macos apache apache2 localhost

在我的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

看起来很奇怪cuz 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

1 个答案:

答案 0 :(得分: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访问时网站无法加载的原因,需要额外的错误/调试日志。