0

Is it possible to configure a VirtualHost for Apache with custom hosts settings without modifying /etc/hosts?

I want a VirtualHost to connect to a different host for testing then my live system. For example, in my /etc/hosts file I would have entries such as:

10.0.0.10    real_db

Where 10.0.0.10 is an IP for my test box and real_db is a link to the live system.

This is a setup I have to work with and changing the code to point to a different server would require touching couple of hundred files.

I am looking for a way to have Apache control which hosts are used depending on which VirtualHost I access.

My other alternative is to write a Bash script to comment/uncomment entries in /etc/hosts, though this approach relies on me remembering to actually do that. I would prefer to stick with something that does not require my input.

Thank you

1 Answer 1

2

No, it is not possible to have Apache httpd modify the DNS resolver settings (or sources) of the system.

Although it doesn't help you right now, you should have your software read its database settings from one configuration file or be able to use environment variables for this (which can be set with SetEnv in the Apache httpd configuration).

1
  • That's the model the code is being moved to, but there is a lot of code to move and the code is very fragile. I was hoping there was a simpler solution. Thanks
    – Misha M
    Nov 5, 2009 at 16:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .