Apache configuration files contain one directive per line. The backslash "\" may be used as the last character on a line to indicate that the directive continues onto the next line. There must be no other characters or white space between the backslash and the end of the line.
Directives in the configuration files are case-insensitive, but arguments to directives are often case sensitive. Lines that begin with the hash character "#" are considered comments, and are ignored. Comments may not be included on a line after a configuration directive. Blank lines and white space occurring before a directive are ignored, so you may indent directives for clarity.
You can check your configuration files for syntax errors without starting the server by using apachectl configtest
or the -t
command line option.
在Apache的配置文件中每一行包含一个指令。反斜杠“\”可能作为下一行的继续标志,指令继续到下一行的最后一个字符。在行的结尾不能有其他字符或空格。在配置文件中的指令是区分大小写的,但往往是大小写敏感的指令参数。每行的开始用散列符“#”作为注释,此行中的所有内容将被忽略。注释不得计入命令行中的配置指令。空行和空格前存在的指令被忽略,所以你可以缩进以标识指令。
你可以使用apachectl configtest 或 -t 命令行选项检查您的配置文件是否存在语法错误。
如下面所示:
- [root@localhost ~]# vim /etc/httpd/conf/httpd.conf
- [root@localhost ~]# service httpd restart
- Stopping httpd: [ OK ]
- Starting httpd: [ OK ]
- [root@localhost ~]# apachectl configtest
- Syntax OK
- [root@localhost ~]# apachectl -
- Syntax OK
- [root@localhost ~]# httpd -t
- Syntax OK
- [root@localhost ~]#