0

我想智能缩进我的 apache2 虚拟主机 conf 文件。我在这里找到了如何智能缩进 xml 文件。但虚拟主机 conf 文件不是有效的 xml 文件。

例如,如果我尝试在 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>
             ^

有没有人知道如何处理这个问题?

4

1 回答 1

0

正如您所说,apache2 配置文件不是 XML 文件。xmllint是一个(除其他外)重新格式化 XML 文件的程序。它不适用于 apache2 配置文件。因此,不要xmllint在 apache2 配置文件上使用,您将避免上面突出显示的错误。

您最好使用编辑器(参见此处了解 emacs apache2 模式),或为重新格式化 apache2 配置文件而编写的程序。

于 2014-10-27T10:45:56.810 回答