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.

On my testing server I want to listen to: 127.0.0.1

and on my productaion server I want to listen to:

.###.###.

I am searching for something like that:

<if #server=>
Listen 127.0.0.1
</if #server=>

There is something like that in apache?

Thank you.

share|improve this question
add comment

3 Answers

up vote 0 down vote accepted

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

<IfDefine TEST>
</IfDefine>

and

<IfDefine !TEST>
</IfDefine>

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: serverfault.com/questions/477970/… –  Shluch Feb 12 '13 at 12:41
add comment

VirtualHost might be what you are needing

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

Or IP based VirtualHost on each server.

<VirtualHost 127.0.0.1:80>
..... Directives.....
</VirtualHost>

etc..

share|improve this answer
add comment

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