We use the following function to auto detect if we are on a machine internally or on a live server and then choose the appropriate configs for various components:
Adding to Andy Shellam's answer..
If you are using mod_vhost_alias, or have various domains with the same (virtual) document root, you can set the variable dependent upon parameters, e.g.
SetEnvIf SERVER_ADDR x.x.x.x APPLICATION_ENV=development
SetEnvIf HTTP_HOST abc.example.com APPLICATION_ENV=development