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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43559201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:51:33  来源:igfitidea点击:

Could not reliably determine the server's fully qualified domain name for MacBook

phpapachehomebrewmacos-sierra

提问by Suresh

First time got a new MBP 2016. Trying to setup PHP,MySQL & Apache. Started Apache by using command

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

sudo apachectl restart

Then installed PHP by

然后通过安装PHP

brew install php71 --with-httpd24

Also did following changes...

也做了以下更改...

#
# 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

Also, updated the same in host file /etc/hosts/

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

But, whenever I'm trying to Stop/Restart my apache by using command sudo apachectl restartor sudo apachectl stopI'm getting following errors.

但是,每当我尝试使用命令停止/重新启动我的 apachesudo apachectl restartsudo 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

But, strangely when I'm executing any PHP file from my browser http://localhost/index.phpit's working fine. As in my index.php file I'm using code <?php phpinfo(); ?>It's showing PHP version PHP Version 7.1.4loaded.

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

Tried a lot but no clude what's going wrong at where.

尝试了很多,但不包括哪里出了什么问题。

---UPDATE---

- -更新 - -

After updating 127.0.0.1 Sureshs-MacBook-Pro.localin my /private/etc/hostsfile, one error solved. Now I'm getting only one below error.

更新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

回答by Suresh

Finally, I solved this by updating ServerName localhost:8080on file /usr/local/etc/apache2/2.4/httpd.conf. It was a differnt httpd.conf file which I didn't knew about it.

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

Also, for Apache start/restart/stopfollowing command sudo /usr/sbin/apachectl startworks for me.

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

回答by kenorb

As per message:

根据消息:

Set the 'ServerName' directive globally to suppress this message.

全局设置“ServerName”指令以抑制此消息。

You need to identify httpd.confApache configuration file by:

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

apachectl -t -D DUMP_INCLUDES

then edit it and uncomment the line with ServerName(make sure it has the valid server name). E.g.

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

ServerName localhost

回答by Dhie Stradlin

open file httpd.conf

打开文件 httpd.conf

vi /etc/httpd/conf/httpd.conf

add to first line

添加到第一行

ServerName localhost

systemctl restart httpd

systemctl 重启 httpd

回答by Vintage Coder

I resolved this issue changing the port address in the httpd.conf file in windows.

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

This problem arises due to the port already listening, which we use in the conf file.

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

To view the port listening, use the command "netview /a"

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

if the port used in the conf file already listening, change to different one(e.g, 8080)

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

set servername to "localhost" or 127.0.0.1

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

Now start the apache server "httpd.exe -k start"

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

it will work fine.

它会正常工作。

回答by Kevin

On macOS Catalina...

在 macOS Catalina 上...

Edit the Apache config file

编辑 Apache 配置文件

sudo vi /etc/apache2/httpd.conf

sudo vi /etc/apache2/httpd.conf

Find the ServerName entry by typing a /followed by ServerNameand hit enter

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

Press nto go to the next occurrence until you are on #ServerName www.example.com:80(keep pressing nif you go past it)

按下n以转到下一个事件,直到您打开#ServerName www.example.com:80n如果您经过它,请继续按下)

Add a newline by typing an o

通过输入一个换行符 o

Type the following: ServerName localhost

键入以下内容: ServerName localhost

Save and exit by typing !wqthen hit enter (or type ZZwhich is capital Z twice)

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

Restart Apache

重启阿帕奇

sudo apachectl restart

sudo apachectl restart