This tutorial series explains how to troubleshoot and fix some of the most common errors that you may encounter when using the Apache web server.
本教程系列说明了如何解决和修复使用Apache Web服务器时可能遇到的一些最常见的错误。
Each tutorial in this series includes descriptions of common Apache configuration, network, filesystem, or permission errors. The series begins with an overview of the commands and log files that you can use to troubleshoot Apache. Subsequent tutorials examine specific errors in detail.
本系列中的每个教程都包含对常见Apache配置,网络,文件系统或权限错误的描述。 本系列文章首先概述了可用于对Apache进行故障排除的命令和日志文件。 后续教程将详细检查特定的错误。
An Apache AH00558: Could not reliably determine the server's fully qualified domain name
message is generated when Apache is not configured with a global ServerName
directive. The message is mainly for informational purposes, and an AH00558 error will not prevent Apache from running correctly.
Apache AH00558: Could not reliably determine the server's fully qualified domain name
当未使用全局ServerName
指令配置Apache时, AH00558: Could not reliably determine the server's fully qualified domain name
消息已生成。 该消息主要用于提供信息,并且AH00558错误不会阻止Apache正常运行。
In this tutorial you will learn how to detect an AH00558 message using the methods described in the How to Troubleshoot Common Apache Errors tutorial at the beginning of this series. You will also learn how to set a ServerName
directive to resolve the message.
在本教程中,您将学习如何使用本系列开始部分的“ 如何对常见Apache错误进行故障排除”教程中描述的方法来检测AH00558消息。 您还将学习如何设置ServerName
指令来解析该消息。
If you have already determined that your Apache server is affected by an AH00558 message and you would like to skip the troubleshooting steps, the Setting a Global ServerName
Directive step at the end of this tutorial explains how to resolve the message.
如果您已经确定AH00558消息影响了Apache服务器,并且希望跳过故障排除步骤,那么本教程末尾的“ 设置全局ServerName
指令”步骤将说明如何解决该消息。
systemctl
故障排除 (Troubleshooting Using systemctl
)The first step when you are troubleshooting an AH00558: Could not reliably determine the server's fully qualified domain name
message is to check Apache’s status using systemctl
. The output from systemctl
will in many cases contain all the information that you need to resolve the message.
对AH00558: Could not reliably determine the server's fully qualified domain name
进行故障排除时的AH00558: Could not reliably determine the server's fully qualified domain name
消息是使用systemctl
检查Apache的状态。 在许多情况下, systemctl
的输出将包含解决消息所需的所有信息。
On Ubuntu and Debian-derived Linux distributions, run the following to check Apache’s status:
在Ubuntu和Debian衍生的Linux发行版上,运行以下命令检查Apache的状态:
On CentOS Fedora, and RedHat-derived systems, use this command to examine Apache’s status:
在CentOS Fedora和RedHat派生的系统上,使用以下命令检查Apache的状态:
The -l
flag will ensure that systemctl
outputs the entire contents of a line, instead of substituting in ellipses (…
) for long lines. The --no-pager
flag will output the entire log to your screen without invoking a tool like less
that only shows a screen of content at a time.
-l
标志将确保systemctl
输出一行的全部内容,而不是用省略号( …
)代替长行。 --no-pager
标志将整个日志输出到您的屏幕,而无需调用诸如less
的工具,该工具一次只显示一个屏幕。
You should receive output that is similar to the following:
您应该收到类似于以下内容的输出:
Output
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Wed 2020-07-29 14:30:03 UTC; 33min ago
Process: 34 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 46 (apache2)
Tasks: 55 (limit: 2344)
CGroup: /system.slice/apache2.service
├─46 /usr/sbin/apache2 -k start
├─47 /usr/sbin/apache2 -k start
└─48 /usr/sbin/apache2 -k start
Jul 29 14:30:03 68e2cf19f3f1 systemd[1]: Starting The Apache HTTP Server...
Jul 29 14:30:03 68e2cf19f3f1 apachectl[34]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Jul 29 14:30:03 68e2cf19f3f1 systemd[1]: Started The Apache HTTP Server.
The highlighted line that contains the AH00558 message is the important one. Essentially, it informs you that Apache couldn’t find a valid ServerName
directive in its configuration file, so it will use the first IP address it detects. In this example, it’s the server’s public IP address: 172.17.02
. If you are troubleshooting an AH00558 message, the IP address that is detected may be different, or it may be a human readable DNS name.
包含AH00558消息的突出显示的行很重要。 本质上,它告知您Apache在其配置文件中找不到有效的ServerName
指令,因此它将使用它检测到的第一个IP地址。 在此示例中,它是服务器的公用IP地址: 172.17.02
。 如果要对AH00558消息进行故障排除,则检测到的IP地址可能不同,或者可能是人类可读的DNS名称。
If your systemctl
output contains an auto-detected value of any IP address or hostname, skip to the last section of this tutorial, Setting a Global ServerName
Directive to resolve the issue. In that section you will configure Apache with a safe default ServerName
value using the IP address for localhost
: 127.0.0.1
.
如果您的systemctl
输出包含自动检测到的任何IP地址或主机名的值,请跳到本教程的最后一部分, 设置全局ServerName
指令来解决此问题。 在该部分中,您将使用localhost
的IP地址使用安全的默认ServerName
值配置Apache: 127.0.0.1
。
If your systemctl
output does not indicate a value that you can use for the ServerName
directive, the next section of this tutorial explains how to examine the systemd
logs using journalctl
to locate an AH00558 message.
如果您的systemctl
输出未指示可用于ServerName
指令的值,则本教程的下一部分将说明如何使用journalctl
检查AH00558消息来检查systemd
日志。
journalctl
故障排除 (Troubleshooting Using journalctl
)To examine the systemd
logs for Apache you will use the journalctl
command. When invoking journalctl
, there are two specific flags that will help you locate specific messages if there is a large volume of log entries.
要检查Apache的systemd
日志,您将使用journalctl
命令。 调用journalctl
,如果有大量日志条目,则有两个特定的标志将帮助您查找特定的消息。
The first flag that you will add to the journalctl
invocation is the --since today
flag. It will limit the output of the command to log entries beginning at 00:00:00 of the current day only. Using this option will help restrict the volume of log entries that you need to examine when checking for errors.
您将添加到journalctl
调用的第一个标志是--since today
标志。 它将命令的输出限制为仅记录当日00:00:00开始的条目。 使用此选项将有助于限制检查错误时需要检查的日志条目的数量。
The second flag that you will use is the same --no-pager
option that you used with systemctl
, which will output the entire log to your screen at once.
您将使用的第二个标志是与systemctl
一起使用的--no-pager
选项,它将立即将整个日志输出到屏幕上。
On Ubuntu and Debian-derived systems, run the following command:
在Ubuntu和Debian衍生的系统上,运行以下命令:
On CentOS, Fedora, and RedHat-derived systems, use this command to inspect the logs:
在CentOS,Fedora和RedHat派生的系统上,使用以下命令检查日志:
If your Apache server is generating an AH00558 message, look through the journalctl
command output for lines like the following:
如果您的Apache服务器正在生成AH00558消息,请在journalctl
命令输出中查找类似以下内容的行:
Output
-- Logs begin at Wed 2020-07-29 14:30:02 UTC, end at Wed 2020-07-29 14:45:03 UTC. --
. . .
Jul 29 14:30:03 68e2cf19f3f1 systemd[1]: Starting The Apache HTTP Server...
Jul 29 14:30:03 68e2cf19f3f1 apachectl[34]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Jul 29 14:30:03 68e2cf19f3f1 systemd[1]: Started The Apache HTTP Server.
The second line of output is the AH00558 message. The line includes the server’s public IP address, which is the address that Apache automatically detects and sets as a default at runtime. With this message as confirmation of an AH00558 error, you can proceed to the Setting a Global ServerName
Directive to resolve the issue.
输出的第二行是AH00558消息。 该行包括服务器的公共IP地址,该地址是Apache在运行时自动检测并设置为默认地址的地址。 使用此消息作为AH00558错误的确认,您可以继续进行“ 设置全局ServerName
指令”来解决此问题。
Otherwise, the next section explains how to diagnose an AH00558 error message using the apachectl
command.
否则,下一节将说明如何使用apachectl
命令诊断AH00558错误消息。
apachectl
故障排除 (Troubleshooting using apachectl
)An AH00558: Could not reliably determine the server's fully qualified domain name
error can be detected using Apache’s apachectl
utility. With apachectl
you can catch messages like these before reloading or restarting Apache, and you can avoid having to search through systemctl
and journalctl
logs to locate errors.
AH00558: Could not reliably determine the server's fully qualified domain name
可以使用Apache的apachectl
实用程序检测到AH00558: Could not reliably determine the server's fully qualified domain name
错误。 使用apachectl
您可以在重新加载或重新启动Apache之前捕获此类消息,并且可以避免通过搜索systemctl
和journalctl
日志来查找错误的位置。
To check your Apache configuration for an AH00558 message, run the following command:
要检查您的Apache配置中是否有AH00558消息,请运行以下命令:
You should receive output like the following if your server is affected by an AH00558 error message:
如果您的服务器受到AH00558错误消息的影响,则应该收到类似以下的输出:
Output
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Syntax OK
As with the previous sections in this tutorial that used systemctl
and journalctl
to locate AH00558 messages, the line that contains the AH00558 message, highlighted in the previous example, is the important one. Again note that the IP address 172.17.0.2
in this example may be different on your server.
与本教程前面的部分使用systemctl
和journalctl
来查找AH00558消息一样,在上一个示例中突出显示的包含AH00558消息的行也很重要。 再次注意,此示例中的IP地址172.17.0.2
在您的服务器上可能不同。
The next section of this tutorial explains how to set the ServerName
directive to resolve AH00558 error messages.
本教程的下一部分将说明如何设置ServerName
指令以解决AH00558错误消息。
ServerName
指令 (Setting a Global ServerName
Directive)To resolve an AH00558: Could not reliably determine the server's fully qualified domain name
error message, you will need to add a ServerName
directive to your Apache configuration. Apache uses the ServerName
directive to map incoming HTTP requests to an IP address or DNS hostname using VirtualHost
directives in order to handle requests for multiple sites using a single server.
解决方案AH00558: Could not reliably determine the server's fully qualified domain name
错误消息,您将需要向AH00558: Could not reliably determine the server's fully qualified domain name
配置中添加ServerName
指令。 Apache使用ServerName
指令使用VirtualHost
指令将传入的HTTP请求映射到IP地址或DNS主机名,以便使用单个服务器处理对多个站点的请求。
The error message notes that a global ServerName
directive should also be set. Doing so will ensure that Apache can gracefully handle incoming requests that do not map to a VirtualHost
without generating additional errors.
该错误消息指出,还应该设置全局ServerName
指令。 这样做将确保Apache可以正常处理不会映射到VirtualHost
传入请求,而不会产生其他错误。
For maximum compatibility with various Apache configurations, use the value of 127.0.0.1
for your global ServerName
directive. You can use a different IP address or DNS name that corresponds to your server’s configuration if you need to, but it is safest to use 127.0.0.1
.
为了最大程度地与各种Apache配置兼容,请为全局ServerName
指令使用值127.0.0.1
。 您可以根据需要使用与服务器配置相对应的其他IP地址或DNS名称,但使用127.0.0.1
最安全。
On Ubuntu and Debian-derived systems, open the /etc/apache2/apache2.conf
file with root privileges using nano
or your preferred text editor:
在Ubuntu和Debian衍生的系统上,使用nano
或您喜欢的文本编辑器以root权限打开/etc/apache2/apache2.conf
文件:
Add a line containing ServerName 127.0.0.1
to the end of the file:
在文件末尾添加包含ServerName 127.0.0.1
的行:
. . .
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ServerName 127.0.0.1
On CentOS, Fedora, and RedHat-derived systems, open the /etc/httpd/conf/httpd.conf
file with root privileges using nano
or your preferred text editor:
在CentOS,Fedora和RedHat派生的系统上,使用nano
或您喜欢的文本编辑器以root特权打开/etc/httpd/conf/httpd.conf
文件:
Add the ServerName 127.0.0.1
line to the end of the file:
将ServerName 127.0.0.1
行添加到文件末尾:
. . .
# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
ServerName 127.0.0.1
Save and close the file when you are finished. If you used nano
, do so by pressing CTRL + X
, Y
, and then ENTER
.
完成后保存并关闭文件。 如果您使用过nano
,请按CTRL + X
, Y
,然后按ENTER
。
Once you have added the ServerName
directive to your configuration, run apachectl
to test that the configuration is valid.
将ServerName
指令添加到配置后,运行apachectl
来测试配置是否有效。
A successful apachectl configtest
invocation should result in output like this:
成功的apachectl configtest
调用应导致如下输出:
Output
Syntax OK
You can now restart Apache using the appropriate systemctl restart
command for your Linux distribution.
现在,您可以使用适用于Linux发行版的适当的systemctl restart
命令来重新启动Apache。
On Ubuntu and Debian-derived systems, run the following:
在Ubuntu和Debian衍生的系统上,运行以下命令:
On CentOS, Fedora, and RedHat-derived systems use this command to restart Apache:
在CentOS,Fedora和RedHat派生的系统上,使用以下命令重新启动Apache:
After you restart Apache, the AH00558 error message will no longer appear in your logs. You can confirm the messages are silenced by running any of the three systemctl
, journalctl
, or apachectl
commands that are demonstrated in this tutorial.
重新启动Apache之后,AH00558错误消息将不再出现在日志中。 您可以通过运行本教程中演示的三个systemctl
, journalctl
或apachectl
命令中的任何一个来确认消息是否静音。
In this tutorial you learned about AH00558: Could not reliably determine the server's fully qualified domain name
error messages. While these messages do not prevent Apache from running, they can be resolved by setting a global ServerName
directive.
在本教程中,您了解了AH00558: Could not reliably determine the server's fully qualified domain name
错误消息。 尽管这些消息不会阻止Apache运行,但是可以通过设置全局ServerName
指令来解决它们。
You learned how to search for AH00558 error messages using the systemctl
, journalctl
, and apachectl
commands. Finally, you learned how to edit your Apache configuration on various Linux distributions to silence the messages.
您学习了如何使用systemctl
, journalctl
和apachectl
命令搜索AH00558错误消息。 最后,您学习了如何在各种Linux发行版上编辑Apache配置以使消息静默。
If you would like to learn more about how Apache uses ServerName
directives, the Apache documentation about Name-Based Virtual Hosts explains the directive in more detail.
如果您想了解有关Apache如何使用ServerName
指令的更多信息,则有关基于名称的虚拟主机的Apache文档将更详细地解释该指令。