Can anyone direct me to a good tutorial on how to set up virtual hosts using Apache 2.2? Here's my situation:

I have Apache running on my laptop and I want two websites-- one on port 80 and one on port 8089. I want to access each site from the other computer on my network by entering the computer's IP address, such as http://192.168.1.102 and http://192.168.1.102:8089. Yet when I enter the second url, it directs me to the website running on port 80.

Thanks in advance for any help.

Accepted Answer

Just have 2 virtual hosts defined like this, but with differeing DocumentRoots:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.somecompany.com
    DocumentRoot "/docs/dummy-host.somecompany.com"
    ServerName dummy-host.somecompany.com
    ServerAlias www.dummy-host.somecompany.com
    ErrorLog "logs/dummy-host.somecompany.com-error.log"
    CustomLog "logs/dummy-host.somecompany.com-access.log" common
</VirtualHost>

<VirtualHost *:8089>
    ServerAdmin webmaster@dummy-host.somecompany.com
    DocumentRoot "/docs/dummy-host.somecompany.com"
    ServerName dummy-host.somecompany.com
    ServerAlias www.dummy-host.somecompany.com
    ErrorLog "logs/dummy-host.somecompany.com-error.log"
    CustomLog "logs/dummy-host.somecompany.com-access.log" common
</VirtualHost>
Written by Visage
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki