Managing IIS/Apache On The Same Server
Internet Information Services (IIS) is Windows' inbuilt webserver platform.
IIS manages multiple websites on the same server by allowing different websites to respond to different host name requests on various ports. So a request for www.site1.com on port 80 will be sent to one web application, and a request for www.site2.com on port 80 will be sent to another. This is despite www.site1.com and www.site2.com resolving to the same public IP address and using the same port. This is achieved via “bindings”. (An incoming request for a site using the public IP address will fail because IIS does not know which web application to send it to.)
Bindings also allow different web services to be available on different local network adaptors where the server has multiple addresses (say 192.168.0.10, 192.168.0.11, 192.168.0.12).
Thus IIS can manage multiple sites across multiple addresses. However, binding web sites to a specific local IP address (say 192.168.0.11) does not change the fact that the W3SVC process will still listen on all adaptors for the desired ports, even if IIS itself will not process requests from all addresses. For example, as shown by the following netstat command:
netstat -an | find ":80"
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING
So if there is a need to run another service on port 80 — most commonly an Apache web server — there are no spare IPs available for the service to listen on.
However both Apache and IIS can be told which adaptors to listen on via manual configuration.
To configure IIS to listen on specific IPs (say localhost and 192.168.0.11), open an elevated command prompt and enter:
netsh http add iplisten ipaddress=127.0.0.1
netsh http add iplisten ipaddress=192.168.0.11
net stop w3svc /y
net start w3svc
To check the IPs listed:
netsh http show iplisten
To remove an IP:
netsh http delete iplisten ipaddress=127.0.0.1
To configure Apache to listen on specific IPs (say 192.168.0.10):
Find the line that reads:
and change it to:
Add another line which reads
Save the file and restart Apache.
Netstat will now show the individual listeners:
TCP 192.168.0.11:80 0.0.0.0:0 LISTENING
TCP 192.168.0.10:80 0.0.0.0:0 LISTENING
TCP 127.0.0.1:80 0.0.0.0:0 LISTENING