Php 尝试了一切;仍然是";“本地主机”;不';无法解决
我有一个运行Yosemite(10.10.3)的iMac,我在上面安装了MAMP,Apache和MySQL启动正常,但我无法访问任何页面,因为localhost无法解析 我尝试了一切,执行了我找到的每一个终端命令,刷新了所有可刷新的内容,修改/删除/添加了我的主机文件中所有可能的组合,重新启动,修改了Mac OS和MAMP的httpd.conf文件中的Php 尝试了一切;仍然是";“本地主机”;不';无法解决,php,apache,localhost,mamp,osx-yosemite,Php,Apache,Localhost,Mamp,Osx Yosemite,我有一个运行Yosemite(10.10.3)的iMac,我在上面安装了MAMP,Apache和MySQL启动正常,但我无法访问任何页面,因为localhost无法解析 我尝试了一切,执行了我找到的每一个终端命令,刷新了所有可刷新的内容,修改/删除/添加了我的主机文件中所有可能的组合,重新启动,修改了Mac OS和MAMP的httpd.conf文件中的ServerName变量,但没有任何东西可以修复它 现在,有趣的是127.0.0.1(:80用于Mac OS Apache或:8888用于WAMP
ServerName
变量,但没有任何东西可以修复它
现在,有趣的是127.0.0.1(:80用于Mac OS Apache或:8888用于WAMP)解决了,我得到了著名的“It works!”,如果我尝试我的Mac name.local(:80用于Mac OS Apache或:8888用于WAMP),就会发生这种情况
我的主机文件如下所示:
##
# 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
fe80::1%lo0 localhost
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:8888
Mac OS Apache httpd.conf文件ServerName
部分如下所示:
##
# 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
fe80::1%lo0 localhost
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:8888
WAMP是这样的:
##
# 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
fe80::1%lo0 localhost
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:80
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:8888
Safari(或任何浏览器)返回:
Ping到localhost返回:
ping: cannot resolve localhost: Unknown host
我已经通过了谷歌给我指出的每一个堆栈溢出、博客、互联网教程,但仍然无法解决这个问题。非常感谢您的帮助。您遇到了什么错误?@SLaks Safari(或任何浏览器)返回:“Safari找不到服务器”Ping返回:“Ping:无法解析本地主机:未知主机”打开终端应用程序并运行
nslookup localhost
,响应是什么?@Twisty服务器:192.168.1.1
地址:192.168.1.1名称:localhost地址:127.0.0.1可能是Safari中的缓存问题。尝试删除缓存。您的操作系统正在将主机名解析为正确的IP,因此应该可以正常工作。可以尝试将conf文件更改为使用*:80
而不是localhost:80