I have two development environments: PC at work (env1), laptop at home (env2). Both machines run Ubuntu 15.10 with Apache 2.4.12. Once finished, the project shall be deployed to a public web server (env3). I use Git for version control and Bitbucket for distributed repository management.
My project is a WordPress powered website. Hence, I add the WordPress root directory, some additional source directories and the latest Mysql database dump SQL file to the development repository, that I am currently working on. If I pull and checkout the latest branch updates on the other environment, I also run the database dump file on the local database. So the dev environments stay consistent all the times including all content and setting changes made to WordPress via admin backend.
However, server names remain different. WP (and I assume other web apps too) have configuration settings like hostname, which are stored in the database, but are actually different on each of the environments. Env1 may operate at a private IP, say 192.168.xxx.yy while env2 may not be connected to a LAN and thus, listen to localhost / 127.0.0.1 only and env3 will need the official host name, say mydomain.com.
My question is, how can I configure the Apache web servers on env1 and env2, that they use some artificial host name, say localdevname for the respective virtual hosts? So I could set WP configuration hostname = localdevname:91
and call localdevname:91 at env1 which resolves to 192.168.xxx.yy:91 while localdevname:91 called at env2 will resolve to localhost:91?
I found a similiar question here. But the only answer doesn't solve my issue. Also, I played around with directives ServerName, ServerAlias, VirtualHostName without success.