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

Sur*_*esh 12 php apache homebrew macos-sierra

第一次获得新的MBP 2016.尝试设置PHP,MySQL和Apache.使用命令启动Apache

sudo apachectl restart
Run Code Online (Sandbox Code Playgroud)

然后安装PHP

brew install php71 --with-httpd24
Run Code Online (Sandbox Code Playgroud)

也做了以下更改......

#
# 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
Run Code Online (Sandbox Code Playgroud)

此外,在主机文件中更新相同 /etc/hosts/

但是,每当我试图通过使用命令停止/重新启动我的apache sudo apachectl restart或者sudo apachectl stop我正在跟踪错误.

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
Run Code Online (Sandbox Code Playgroud)

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

试了很多,但没有弄清楚在哪里出了什么问题.

--- 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
Run Code Online (Sandbox Code Playgroud)

Sur*_*esh 21

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

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

  • 谢谢...对于mac用户:你可以在路径`/usr/local/etc/httpd/httpd.conf`中找到你的`httpd.conf`文件 (2认同)

ken*_*orb 15

根据消息:

全局设置"ServerName"指令以禁止显示此消息.

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

apachectl -t -D DUMP_INCLUDES
Run Code Online (Sandbox Code Playgroud)

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

ServerName localhost
Run Code Online (Sandbox Code Playgroud)


小智 5

打开文件httpd.conf

vi /etc/httpd/conf/httpd.conf
Run Code Online (Sandbox Code Playgroud)

添加到第一行

ServerName localhost
Run Code Online (Sandbox Code Playgroud)

systemctl重启httpd