How to configure virtual hosts on Apache 2.2

Can someone direct me to a good tutorial on setting up virtual hosts using Apache 2.2? Here is 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 another computer on my network by specifying the IP address of the computer, for example http : //192.168.1.102 and http://192.168.1.102:8089 . However, when I enter the second URL, it directs me to a site running on port 80.

Thanks in advance for your help.

+4
source share
2 answers

You just have 2 virtual hosts, but with different 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> 
+1
source

First you need to tell Apache to listen on the ports you need:

 Listen 80 Listen 8089 

Secondly, you need to say what to do with traffic 80 and 8089:

 <VirtualHost *:80> DocumentRoot /website/site80 ServerName internet.dev </VirtualHost> <VirtualHost *:8089> DocumentRoot /website/site8089 </VirtualHost> 

Third, you need to "allow" Apache to use these directories:

 <Directory "C:/website/site80"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> <Directory "C:/website/site8089"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> 
+4
source

All Articles