Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
1  
Why didn't you use VirtualHost? –  quanta Aug 15 '11 at 9:33
    
please see my edit –  Owen Aug 15 '11 at 10:21
    
This is and keeps beeing a duplikate of serverfault.com/questions/300943/… –  mailq Aug 15 '11 at 14:07

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer

In my host file I have

127.0.0.1     example.dev:8080

The hosts file cannot understand the port. Stop trying.

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>

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.