1

We have several different environments (developer dekstop, integration, QA, prod) which should have slightly different variants of the same httpd.conf file. As an example, the httpd.conf file configures that httpd should act as a reverse proxy and proxy certain URLs to Jetty, but the hostname of the Jetty instance is different in each environment.

Is there a recommended practice for mangaging these kinds of differences? I looked around the apache documentation for the httpd.conf file and I didn't see anything that does what I need.

James Kingsbery
  • 309
  • 1
  • 2
  • 8

1 Answers1

4

Split the unique sections into separate files, then use Include directives in the main http.conf to include other config files. You could for example wrap those Includes in IfDefine sections and then use the -D command-line startup option to define variables to turn on or off different sections of the config:

<IfDefine DEVELOPER>  
  Include developer.conf
</IfDefine>

and then:

apachectl start -D DEVELOPER

It feel cleaner to me to use included conf files, but of course you could put all your config in one file inside ifdefs too.

Bonus points for automating all of this with a config management tool like cfengine or puppet, of course.

Phil Hollenback
  • 14,947
  • 4
  • 35
  • 52
  • 1
    This is the right way to go about doing this. Good answer Phil. – blueben Jan 12 '11 at 01:08
  • Thanks Ben! It's funny because up until now I'd never actually thought about how to make that happen. I learned something too. – Phil Hollenback Jan 12 '11 at 01:58
  • Thanks! That's exactly what I'm looking for. We use bash scripts wired into our continuous integration to keep them up to date, so we only get partial credit on the bonus points. – James Kingsbery Jan 12 '11 at 15:44