Apache httpd.conf 配置文件语法验证

Apache 的 httpd.conf文件改动之后,必须重新启动server才干生效。

有时server在提供服务的时候,直接更改配置,重新启动服务。会带来非常大的危急性。

假设能在改动配置之后,先验证语法正确与否,再重新启动server。则能避免一些不必要的错误。

对以上需求,Apache本身提供了对应的命令来验证配置文件的语法。

Windows环境的命令:

httpd -t


Linux环境的命令:
[root@server bin]# ./apachectl configtest


假设正确无误。会显示Syntax OK信息
Syntax OK

假设存在错误,则会显示出错的行号以及错误信息。例如以下:
AH00526: Syntax error on line 339 of /opt/apache/conf/httpd.conf:

Invalid command 'a', perhaps misspelled or defined by a module not included in the server configuration


原文地址:https://www.cnblogs.com/zhchoutai/p/7091240.html