David Cramer posted this excellent article back in 2011 about how they handle their config files. In a multi-environment setup (dev, stage, prod) this is paramount.
In his example he makes use of an environment variable to set which configuration to use. While this is probably ideal, it’s not always an option. As a replacement, you could use the IP address or host name of the machine: