I have a working installation of apache and mysql using standard ports, and my host file points domains to 127.0.0.1.
I'm in the process of switching my LAMP stack to Zend Server but want my old set up working simultaneously.
I tried switching the old apache port to 8080, and a different port for the old mysql. This seems to work OK (apache is working, mysql is listening on the new port but I've not tried a database connection).
However my problem is that I can't map domains to 8080 on localhost because host file doesn't handle ports, just IP address.
I should mention that I'm on a Windows machine.
Any ideas how I would solve this so I can use hosts file to map domains to 2 different LAMP stacks?
Edit
Regarding hosts file and virtualhost - When I go to localhost I get my new Zend apache running, when I go to localhost:8080 I have my old apache document root. This is as expected.
However I can't get hosts file and virtual hosts working on :8080. In my host file I have
127.0.0.1 example.dev:8080
and in my virtualhosts (httpd-vhosts.conf on my old apache instance, not my Zend instance) I have
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "C:\xampp\htdocs\example.dev"
ServerName example.dev
</VirtualHost>
Now when I try example.dev in my browser I get 'server not found' so I think that the virtualhosts did not work.
While hosts won't map ports, you should be able to access the two instances using their ports and hostnames, I.E. http://site1:8080/, http://site2:80/. Or if you really need to have both accesible on a single port, move the new stack to a port like 8081 and set up NGINX, HAProxy, Squid or even another Apache instance to proxy the sites from one port.
The hosts file cannot understand the port. Stop trying.
VirtualHost means that you can run multiple web sites on a single IP address. So that, change port to 80, specific a ServerName for DocumentRoot
C:/xampp/htdocs
and try again.