Jul.07

Running IIS and Apache on Same Server at the Same Time

Running IIS and Apache on Same Server at the Same Time

It is possible to run both IIS and Apache on the same Windows machine, both using port 80 (http) and 443 (https), without any start-up or conflict issues.

To do this, you simply configure IIS and Apache to use different interfaces (i.e., IP addresses) with: one web-server binding on the Public IP address, and the other web-server binding on 127.0.0.1 (local host). Depending on your situation and needs, you can also assign the LAN IP to either IIS or Apache (…just ask yourself which web-server do you want reachable on the local/internal network?).

This way you’ll have both web-servers, and their hosted websites, using standard ports (with no need to use non standard URLs), just on different IPs.

With this method (for example), you could keep your existing IIS websites in production, while at the same time developing on and/or migrating to Apache (which is accessible on the local host). Later, you can move Apache to production by re-binding it.

1. Rebind all IIS websites (including “Default Web Site”) from “*” and “0.0.0.0” (“0.0.0.0″ means all IPs the system has) to the Public IP address… Select each website one by one, and in the Action pane, click Bindings.

2. Bind Apache from 0.0.0.0 to 127.0.0.1 per these simple instructions…
Binding Apache to a Specific Or [local] Secondary IP Address

Note that when you install a WAMP server such as WampDeveloper Pro, it will stop the IIS Service and change its “Startup Type” from “Automatic” to “Disabled”…

To minimize production downtime, after WAMP installation –

  1. Stop Apache.
  2. Go into Services (run services.msc), select the IIS Service (W3SVC / “World Wide Web Publishing Service”), change its startup type back to “Auto”, and start it.
  3. Rebind all IIS websites to the public IP address, and restart IIS.
  4. Rebind Apache to 127.0.0.1 per the above instructions, and start it.

Binding Apache to a Specific Or Secondary IP Address

Running IIS and Apache in same machine [single computer] Apache, by default, will attempt to bind to and listen on these interfaces:

0.0.0.0:80
0.0.0.0:443

[::]:80
[::]:443

1. “0.0.0.0” means ALL IPv4 addresses that the system has (including 127.0.0.1).   2. “::” means ALL IPv6 addresses that the system has (including ::1). When started, Apache will try to take all the IP addresses of the system, and if you are already running another web-server (such as IIS, Tomcat, Nginx, Jetty, Domino, etc) on that same system, Apache will not be able to bind to “0.0.0.0” and “::”, and will fail to start. Or, if started first, after binding to all the available IP addresses, it will prevent the other web-server form starting. To bind Apache to a specific or secondary IP address: Edit file – C:\WampDeveloper\Config\Apache\httpd.conf Find and replace these two lines (one is at the beginning, the other at the end) –

Listen 80
...
Listen 443

With –

Listen ip.address.here:80
...
Listen ip.address.here:443

You can specify multiple IP addresses with multiple lines. If this is a public server, make sure that the IP addresses you are using, are either the resolvable IP addresses of your Apache hosted domain names (e.g., the Public IP address), or the LAN IP addresses that the Router is port-forwarding outside port 80 and 443 traffic to. If this is a intranet server, you can just bind Apache to the LAN IP. If this is a localhost server, you can just bind Apache to 127.0.0.1. Also make sure that your other web-server is binding only to a specific IP address, and not to “0.0.0.0”. After making changes, if Apache won’t start, check the configuration by running (from the command line):

httpd -t -n "Apache2"
httpd -k start -n "Apache2"