天天看點

Apache指令——文法檢查

原文:Syntax of the Configuration Files

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的配置檔案中每一行包含一個指令。反斜杠“\”可能作為下一行的繼續标志,指令繼續到下一行的最後一個字元。在行的結尾不能有其他字元或空格。在配置檔案中的指令是區分大小寫的,但往往是大小寫敏感的指令參數。每行的開始用散列符“#”作為注釋,此行中的所有内容将被忽略。注釋不得計入指令行中的配置指令。空行和空格前存在的指令被忽略,是以你可以縮進以辨別指令。

  1. [root@localhost ~]# vim /etc/httpd/conf/httpd.conf 
  2. [root@localhost ~]# service httpd restart 
  3. Stopping httpd:                                   [  OK  ] 
  4. Starting httpd:                                   [  OK  ] 
  5. [root@localhost ~]# apachectl configtest 
  6. Syntax OK 
  7. [root@localhost ~]# apachectl -
  8. Syntax OK
  9. [root@localhost ~]# httpd -t
  • Syntax OK
  • [root@localhost ~]#