【问题标题】:Could not reliably determine the server's fully qualified domain name for MacBook无法可靠地确定服务器的 MacBook 完全限定域名
【发布时间】:2017-04-22 12:28:07
【问题描述】:

第一次得到一个新的 MBP 2016。尝试设置 PHP、MySQL 和 Apache。使用命令启动 Apache

sudo apachectl restart

然后通过

安装PHP
brew install php71 --with-httpd24

还进行了以下更改...

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#

DirectoryIndex index.html index.php
SetHandler application/x-httpd-php

ServerName dev-server

另外,更新主机文件/etc/hosts/

但是,每当我尝试使用命令 sudo apachectl restartsudo apachectl stop 停止/重新启动我的 apache 时,我都会遇到以下错误。

AH00557: httpd: apr_sockaddr_info_get() failed for Sureshs-MacBook-Pro.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
httpd not running, trying to start

但是,奇怪的是,当我从浏览器http://localhost/index.php 执行任何 PHP 文件时,它工作正常。在我的 index.php 文件中,我使用代码 <?php phpinfo(); ?> 它显示 PHP 版本 PHP Version 7.1.4 已加载。

尝试了很多,但不知道哪里出了问题。

---更新---

在我的/private/etc/hosts 文件中更新127.0.0.1 Sureshs-MacBook-Pro.local 后,解决了一个错误。现在我只得到以下错误。

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Sureshs-MacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message

【问题讨论】:

  • 在您的 apache 配置中添加 serverName = my.server.name 指令可能会解决您收到的警告。
  • 我已经将它添加为ServerName dev-server。看我的帖子
  • 尝试不带连字符的 ServerName 值并给出端口值。例如:服务器名称 devserver:80
  • @NagaPenmetsa 我终于弄清楚了我的问题是什么。我已经在帖子中回复了答案。不过感谢您的回复。

标签: php apache homebrew macos-sierra


【解决方案1】:

最后,我通过更新文件/usr/local/etc/apache2/2.4/httpd.conf 上的ServerName localhost:8080 解决了这个问题。这是一个我不知道的不同的 httpd.conf 文件。

此外,对于 Apache start/restart/stop,以下命令 sudo /usr/sbin/apachectl start 对我有用。

【讨论】:

  • 我尝试了你所建议的所有方法,但仍然有同样的问题,如果我执行 php -v 我看到正确的 php 7 版本但无法让 apache 重新启动,总是会出现这个错误 AH00558: httpd:无法使用 vaske-mbp.local 可靠地确定服务器的完全限定域名。全局设置“ServerName”指令以禁止显示此消息。我通过添加 127.0.0.1 vaske-mbp.local 扩展了 etc 主机,但它根本没有帮助。
  • 谢谢... 对于 mac 用户:您可以在路径 /usr/local/etc/httpd/httpd.conf 找到您的 httpd.conf 文件
【解决方案2】:

根据消息:

全局设置“ServerName”指令以禁止显示此消息。

您需要通过以下方式识别httpd.conf Apache 配置文件:

apachectl -t -D DUMP_INCLUDES

然后编辑它并取消注释ServerName (确保它具有有效的服务器名称)。例如

ServerName localhost

【讨论】:

  • 我正在对其他一些 httpd.conf 进行更改,并且由于没有得到任何更改而即将扔掉我的 mac。你救了我的mac! :D 非常感谢。如果您能告诉如何更改 apache 的 httpd.conf 文件的路径,这也会很有帮助
  • 非常感谢!有太多的 httpd.conf 文件在加载,我不确定哪个是实际使用的 :)
【解决方案3】:

打开文件 httpd.conf

vi /etc/httpd/conf/httpd.conf

添加到第一行

ServerName localhost

systemctl 重启 httpd

【讨论】:

    【解决方案4】:

    我解决了这个问题,在 windows 中更改 httpd.conf 文件中的端口地址。

    这个问题是由于我们在 conf 文件中使用的端口已经在侦听。

    查看端口监听,使用命令“netview /a”

    如果 conf 文件中使用的端口已经在监听,则更改为其他端口(例如 8080)

    将服务器名称设置为“localhost”或 127.0.0.1

    现在启动apache服务器“httpd.exe -k start”

    它会正常工作的。

    【讨论】:

      【解决方案5】:

      在 macOS Catalina 上...

      编辑 Apache 配置文件

      sudo vi /etc/apache2/httpd.conf

      通过键入/ 后跟ServerName 并点击enter 来查找ServerName 条目

      n 转到下一个匹配项,直到您在#ServerName www.example.com:80 上(如果您跳过它,请继续按n

      通过输入 o 添加换行符

      键入以下内容:ServerName localhost

      输入!wq 保存并退出,然后按回车键(或输入ZZ 两次大写Z)

      重启 Apache

      sudo apachectl restart

      【讨论】:

        猜你喜欢
        • 2011-08-16
        • 2013-08-19
        • 2018-05-19
        • 2021-05-29
        • 2022-07-18
        • 2015-10-15
        • 2021-08-14
        • 1970-01-01
        • 2012-03-21
        相关资源
        最近更新 更多