重构Apacheconfiguration文件的工具

我正面临着清理一个不合理的Apacheconfiguration的问题。 它积累了近十年的土地。 我正在重构它,修复tab / indentation,把部分分解成包含。

你有任何有用的脚本/技术/ bbeditconfiguration文件或关于保持有组织的Apacheconfiguration的一般build议? 有没有关于正确组织Apacheconfiguration的书籍/网站?

我曾经不得不处理这样一个文件,每当公司收购了另外一家公司,他们把品牌join到1GB的httpd.conf文件中,不同的品牌就必须在不同的testing环境中进行testing。 我们的做法是:

  1. 从一个新的空文件开始,只包含需要包含的东西。 如果您有版本控制系统,请将其保存。
  2. 使用include指令。 这可以让您启用禁用整个品牌。
  3. 使用一个模板系统来创build虚拟主机,如下图所示,有十几个品牌。 在5或6个环境中运行
  4. 使用由业务创build的电子表格来创build虚拟主机文件。 这与perl excelparsing器模块很好地工作。 最后,业务分析师可以更改电子表格并获得一组新的虚拟主机,pipe理员很高兴,因为他们可以通过在httpd.conf中注释/启用一行来禁用/启用环境。
  5. grep所有注释行和空白行。 通过删除所有间距和注释,将5000行文件减less到2000时,似乎不那么令人生畏。

 # Begin Virtual Host: [% brand_description %] Listen [% dyn_ip %]:[% dyn_port %] <VirtualHost [% dyn_ip %]:[% dyn_port %]> ServerAdmin [% server_admin %] ServerName [% dyn_ip %]:[% dyn_port %] DocumentRoot "[% document_root %]" <Directory /> DirectoryIndex index.html Options Indexes FollowSymLinks AllowOverride None </Directory> ErrorLog [% error_log %] CustomLog [% custom_log %] combined JKMount [% jk_mount_point %] [% jk_balancer_name %] ErrorDocument 502 /holding/50x_disruption-page.html ErrorDocument 503 /holding/50x_disruption-page.html RedirectPermanent [% payment_page %] [% brand_payment_url %] </VirtualHost> # End Virtual Host: [% brand_description %]