在CentOS 7服务器中,在以下位置sudo apachectl restart添加包含文件后输入时,出现以下错误httpd.conf:
Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.
当我输入时sudo systemctl status httpd.service -l,结果是:
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: failed (Result: exit-code) since Tue 2014-12-23 20:10:37 EST; 2min 15s ago
Process: 2101 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Process: 2099 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 2099 (code=exited, status=1/FAILURE)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Dec 23 20:10:37 ip-address httpd[2099]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e23f:49ff:feb7:2a21. Set the 'ServerName' directive globally to suppress this message
Dec 23 20:10:37 ip-address systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Dec 23 20:10:37 ip-address systemd[1]: Failed to start The Apache HTTP Server.
Dec 23 20:10:37 ip-address systemd[1]: Unit httpd.service entered failed state.
我可以apache,如果我注释掉include指令重新启动,我可以通过取消注释include指令再次重现错误。 如何才能apache开始正确使用包含文件的内容?
httpd.conf触发该错误的底部的行是:IncludeOptional sites-enabled/*.conf。.conf文件sites-enabled夹中唯一的文件是mydomain.com.conf,其内容如下:
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/mydomain.com/public_html
ErrorLog /var/www/mydomain.com/error.log
CustomLog /var/www/mydomain.com/requests.log combined
</VirtualHost>
该httpd.conf是一样什么都预安装有httpd,除了一行包括上面的指令。我知道,因为我没有sudo yum remove httpd mod_ssl和sudo yum install httpd mod_ssl右触发这个错误之前。单击此链接,httpd.conf可以在文件共享站点中读取整个内容。
当我明确遵循本教程中的步骤时,我遇到了此问题。
当我注释掉包含文件时,http/mydomain.com成功提供了位于中的静态内容/var/www/html,这是中的DocumentRoot定义httpd.conf。问题似乎来自VirtualHost上面显示的包含文件中的指令。 为了帮助诊断,我在下面的EDIT#3中.conf提供了指向的三个include指令中包含的所有文件的链接httpd.conf。
编辑#1
当我尝试m32的建议将更/etc/hostname改为define时mydomain.com,apache仍然不会重新启动,并且systemctl status httpd.service结果如下:
[sudo_user_account@server-ip-address ~]$ sudo systemctl status httpd.service -l
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: failed (Result: exit-code) since Tue 2014-12-23 14:25:35 EST; 20s ago
Process: 31993 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Process: 31991 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 31991 (code=exited, status=1/FAILURE)
Status: "Total requests: 1; Current requests/sec: 0; Current traffic: 0 B/sec"
Dec 23 14:25:35 hostname systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Dec 23 14:25:35 hostname systemd[1]: Failed to start The Apache HTTP Server.
Dec 23 14:25:35 hostname systemd[1]: Unit httpd.service entered failed state.
编辑#2
我还尝试了eyoung100的建议来更改/etc/hosts文件的内容,如下图所示,但仍然收到上面EDIT#1中定义的错误。
编辑#3
根据DerekC的要求,我跑步sudo apachectl configtest并得到:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e23f:49ff:feb7:2a21. Set the 'ServerName' directive globally to suppress this message
Syntax OK
另外,根据GarethTheRed的建议,我检查了httpd.conf中的include指令。httpd.conf中包含三个include指令。我在下面列出了这三个文件,以及每个指令的文件夹中的所有文件。这些都是.conf随一起安装的标准文件httpd。我还没有修改它们。您可以.conf通过单击以下链接在文件共享站点上查看每个文件:
Include conf.modules.d/*.conf引用conf.modules.d目录中的以下文件:
00-base.conf
00-dav.conf
00-lua.conf
00-mpm.conf
00-proxy.conf
00-ssl.conf
00-systemd.conf
01-cgi.conf
IncludeOptional conf.d/*.conf引用conf.d目录中的以下文件:
autoindex.conf
ssl.conf
userdir.conf
welcome.conf
还有一个自述文件,我在这里省略。
此外,该IncludeOptional sites-enabled/*.conf指令及其内容已在上面的OP中进行了概述。
这些包含文件中的任何一个是否与中的VirtualHost设置冲突mydomain.com.conf?
编辑#4
每garethTheRed的建议,我感动mydomain.com.conf的conf.d目录,然后开始注释掉线mydomain.com.conf由一个一个,直到httpd能够重新启动。然后,我开始取消注释行,以查看可以保留多少行并httpd仍然重新启动。我能够httpd重新启动,但systemctl status httpd.service -l继续产生相同的警告:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e23f:49ff:feb7:2a21. Set the 'ServerName' directive globally to suppress this message
VirtualHost允许httpd启动的语法(尽管继续生成上述警告)如下:
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/mydomain.com/public_html
</VirtualHost>
请注意,我必须省略以下几行,这些行的存在将警告升级为完全无法启动http:
# ErrorLog /var/www/mydomain.com/error.log
# CustomLog /var/www/mydomain.com/requests.log combined
另外,我跑sudo journalctl -xelu httpd了,终端通过重复以下多次回答:
--
-- Unit httpd.service has finished shutting down.
Dec 24 17:48:43 server-ip-address systemd[1]: Stopped The Apache HTTP Server.
-- Subject: Unit httpd.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has finished shutting down.
Dec 24 17:48:48 server-ip-address systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Dec 24 17:48:48 server-ip-address httpd[10364]: AH00558: httpd: Could not reliably d
Dec 24 17:48:48 server-ip-address systemd[1]: Started The Apache HTTP Server.
-- Subject: Unit httpd.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has finished starting up.
--
-- The start-up result is done.
lines 887-909/909 (END)
注意:无论使用eyoung100的主机文件还是m32的主机文件,以上结果均保持不变。 为了回答这个问题,我认为我应该能够创建日志文件,并且还可以避免服务器名警告。 否则,我担心配置httpd的后续步骤将容易出现挥之不去的错误。
apachectl configtest什么?
IncludeOptional原始httpd.conf文件的末尾是否有一个?我相信这里是默认安装。问题可能是您IncludeOptional在末尾添加了额外的内容,从而迫使apache其两次读取所包含的配置文件,从而导致其失败。
mydomain.com.conf到/etc/httpd/conf.d(所有其他位置)并删除/etc/httpd/sites-enabled(这是Debian / Ubuntu的事情),然后将IncludeOptional您添加到中httpd.conf。您可以AH00558暂时忽略该消息,因为它不会停止apache。接下来,从conf文件中删除一行,直到找到罪魁祸首(或者,从一个空行开始,然后一次恢复一行)。
ServerName指令时会产生什么确切的“模糊”错误?将其添加到您的问题。