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

On my testing server I want to listen to:

and on my productaion server I want to listen to:


I am searching for something like that:

<if #server=>
</if #server=>

There is something like that in apache?

Thank you.

share|improve this question
up vote 0 down vote accepted

You can add -DTEST to the httpd command line and then use

<IfDefine TEST>


<IfDefine !TEST>

to enable different sections of the config file.

share|improve this answer
Can I do it without command line? like reading from the system environment? – Shluch Feb 12 '13 at 10:44
Not that I'm aware of, but if you use a script to start httpd you could do the test there, e.g httpd -D${MYENVVAR:-PRODUCTION} – Per Johansson Feb 12 '13 at 12:21
Thank you very much, I added other question about the same topic:… – Shluch Feb 12 '13 at 12:41

VirtualHost might be what you are needing

<VirtualHost *:80>
..... Directives.....

Or IP based VirtualHost on each server.

..... Directives.....


share|improve this answer

Could you just run two separate apache instances listening on separate ports. There would be less of a chance of the testing environment causing problems for your production server. Also restarts would not affect your production environment

share|improve this answer
No, this is two differences server. (My office, and Web farm). I want to be able to just copy the httpd.conf every time I change something. – Shluch Feb 12 '13 at 7:04

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.