Apache命令——语法检查

本文详细介绍了Apache配置文件的基本语法和使用技巧,包括如何利用反斜杠进行行续接、注释的使用方法以及如何检查配置文件的语法错误等内容。

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 命令行选项检查您的配置文件是否存在语法错误。

如下面所示:

 
 
  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 ~]#

 



本文转自 urey_pp 51CTO博客,原文链接:http://blog.51cto.com/dgd2010/820206,如需转载请自行联系原作者


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值