Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
</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.

share|improve this answer
1  
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
add comment

Your Answer

 
discard

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.