0

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.

Shluch
  • 103
  • 4

3 Answers3

1

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

Mattrix
  • 33
  • 5
0

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

trent
  • 3,114
  • 19
  • 17
  • 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 07:04
0

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.

  • 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: http://serverfault.com/questions/477970/can-i-add-argument-to-httpd-when-i-am-using-xampp – Shluch Feb 12 '13 at 12:41