运行 Apache 的 configtest 时确定有问题的文件

运行 Apache 的 configtest 时确定有问题的文件

有没有办法在运行时确定有问题的文件https configtest

例如,而不是:

Warning: DocumentRoot [/var/www/whatever.com/webroot] does not exist
Warning: DocumentRoot [/var/www/example.com/webroot] does not exist

我能看见:

Warning: DocumentRoot [/var/www/whatever.com/webroot] does not exist in /etc/httpd/conf.d/file.conf
Warning: DocumentRoot [/var/www/example.com/webroot] does not exist in /etc/httpd/conf.d/other_file.conf

我查看了帮助/手册并进行了搜索,但找不到选项或等效命令。

答案1

不幸的是,apachectl 没有提供这些信息。

最好的解决方案就是简单地使用grep在配置文件中搜索错误消息中显示的字符串。

答案2

仅添加一些额外的信息,该apachectl脚本本身并没有做太多事情,只是httpd用标志调用二进制文件:

 configtest)
    $HTTPD -t
    ERROR=$?
    ;;

因此,这个问题必须在核心本身中解决。

此问题已修复apache-2.4

# systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: failed (Result: exit-code) since Fri 2014-06-20 20:36:01 CEST; 1s ago
  Process: 3331 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
  Process: 3329 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 3329 (code=exited, status=1/FAILURE)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"

Jun 20 20:36:01 foo.com httpd[3329]: AH00526: Syntax error on line 15 of /etc/httpd/conf.d/012-some-vhost.conf:
Jun 20 20:36:01 foo.com httpd[3329]: Invalid command 'UseCanonicalNamex', perhaps misspelled or defined by a module not included in the server configuration
Jun 20 20:36:01 foo.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jun 20 20:36:01 foo.com systemd[1]: Failed to start The Apache HTTP Server.
Jun 20 20:36:01 foo.com systemd[1]: Unit httpd.service entered failed state.

相关代码在server/config.c

答案3

基于教程检查/etc/apache2/extra/httpd-vhosts.conf。这在我的 OSX 10.13 机器上使用 Apache 2.4。

相关内容