Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 4 down vote accepted

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

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.

share|improve this answer
This is the right way to go about doing this. Good answer Phil. – blueben Jan 12 '11 at 1: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 1: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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.