2014-10-27 46 views
0

我想智能缩进我的apache2虚拟主机conf文件。 我找到here如何智能缩进xml文件。但虚拟主机conf文件不是有效的xml文件。使用xmllint格式apache2虚拟主机conf

举例来说,如果我尝试使用其上的Apache2的库提供的000-default.conf xmllint,我得到一个错误:

$ cat 000-default.conf | xmllint --format - 
-:1: parser error : error parsing attribute name 
<VirtualHost *:80> 
      ^
-:1: parser error : attributes construct error 
<VirtualHost *:80> 
      ^
-:1: parser error : Couldn't find end of Start Tag VirtualHost line 1 
<VirtualHost *:80> 
      ^
-:1: parser error : Extra content at the end of the document 
<VirtualHost *:80> 
      ^

没有任何一个有关于如何处理这个线索?

回答

0

正如你所说,apache2配置文件不是XML文件。 xmllint是一个程序(特别是)重新格式化XML文件。它不会在apache2配置文件上工作。因此,不要在apache2配置文件上使用xmllint,并且您将避免上面突出显示的错误。

你会更好地使用编辑器(请参阅here for emacs apache2模式),或编写用于重新格式化apache2配置文件的程序。

+0

谢谢你的回答。我不明白你的句子'因此,请在apache2配置文件上使用xmllint,并且避免上面突出显示的错误。' – Dionys 2014-10-27 10:53:17

+0

它缺少重要的词'不' - 现在已修复。 – abligh 2014-10-27 17:07:10