无法可靠地确定服务器的MacBook完全限定域名

时间:2017-04-22 12:28:07

标签: php apache homebrew macos-sierra

第一次获得新的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

尝试了很多,但没有弄清楚在哪里出了问题。

--- --- UPDATE

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

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

5 个答案:

答案 0 :(得分:20)

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

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

答案 1 :(得分:12)

根据消息:

  

设置&#39; ServerName&#39;全局指令抑制此消息。

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

apachectl -t -D DUMP_INCLUDES

然后编辑它并使用ServerName取消注释该行(确保它具有有效的服务器名称)。 E.g。

ServerName localhost

答案 2 :(得分:5)

打开文件httpd.conf

vi /etc/httpd/conf/httpd.conf

添加到第一行

ServerName localhost

systemctl重新启动httpd

答案 3 :(得分:0)

我已解决此问题,更改了Windows中httpd.conf文件中的端口地址。

由于端口已在监听,我们在conf文件中使用该端口,因此会出现此问题。

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

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

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

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

它将正常工作。

答案 4 :(得分:0)

在macOS Catalina上...

编辑Apache配置文件

sudo vi /etc/apache2/httpd.conf

通过键入/后接ServerName来找到ServerName条目,然后点击enter

n转到下一次出现,直到您停留在#ServerName www.example.com:80上(如果经过n则继续按)

通过键入o

添加换行符

键入以下内容:ServerName localhost

通过输入!wq保存并退出,然后按Enter键(或输入两次大写字母Z的ZZ

重新启动Apache

sudo apachectl restart