Take the 2-minute tour ×

I am facing a taks of cleaning up an unreasonably big Apache config. It accumulated crud over almost a decade. I am starting with refactoring it, fixing tabbing/indentation, breaking out sections into includes.

Do you have any useful scripts / techniques / bbedit config files or general advice on keeping an organized apache config? Are there any books / websites that focus on properly organizing Apache configs?

share|improve this question

1 Answer 1

I once had to deal with such a file, each time the company bought out another company they added their brands into the 1 BIG httpd.conf file, different brands had to be tested in different test environments. Our approach was:

  1. Start with a new empty file and include only things that needed to be included. Keep it in a version control system if you have one.
  2. Use include directive. This lets you enable disable entire brands.
  3. Use a Template system to create virtual hosts, like below, with over a dozen brands. running accross 5 or 6 environments
  4. Use a spreadsheet created by the business to create the virtual hosts files. This worked well with the perl excel parser module. In the end the business analysts could just change the spreadsheet and get a new set of virtual hosts for inclusion and the admins were happy because they could disable/enable enviroments by commenting/enabling a single line in httpd.conf.
  5. grep out all the comment lines and blank lines. It seems less daunting when you reduce a 5000 line file to 2000 by removing all the spacing and comments.

# 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

    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 %]
# End Virtual Host: [% brand_description %]
share|improve this answer

Your Answer


