Running Apache and IIS on the same web server might seem like sacrilege to some folks, but like a lot of things in life there is a time and a place for everything. I’ve overseen some quite successful deployments that have had the two running side by side on the same machine, and the flexibility that Apache can bring to an application as a value add can be really exciting. For both future keepsake and to share with all of you folk, here is a quick how-to guide so that all you have to do is follow the bouncing ball.
Apache on Windows you say?
At this point you might be asking why on earth I would want to do this at all. IIS is a perfectly good webserver and has great support for everything under the sun (Ruby? PHP?) you name it since WebMatrix was launched a year or two ago.
The problem is that there is a number of different web sites and application packages that specifically target Apache and its associated packages such as mod_rewrite – and as I’m sure you are aware all know, the thought of rewriting legacy software you or a client has purchased just to make it work on IIS is not really what you’d like to spend your time doing.
For times like these, running Apache is a no-brainer. But what if you already have a server running IIS and you don’t want another server to manage and pay for? This is a time where installing the Windows version of Apache web server side by side with IIS sounds like a great idea.
A few problems to overcome
IIS is used to running in quite an integrated manner with the rest of Windows. IIS is also used to being the only service listening on IP addresses and their port bindings (specifically every IP address available on TCP port 80). Installing Apache side by side is not a problem. Running them both simultaneously is.
We need to turn IIS’s list of “All Unassigned” into a list of only the IP addresses that we want IIS to control. This allows us to then give Apache some separate ones to its own. They can both run on port 80, its just that IIS wont try and grab port 80 on the whole lot.
What you’ll need
- Windows 7 or Windows Server 2008 (this works for 2003 as well, but the command line configuration is slightly different)
- IIS Installed
Steps to make it happen
Install Apache, or a mashup of your liking ( XAMP ?? )
Select what IP addresses you’d like Apache to run on, and enter these bindings into the httpd.conf (go here for more information on how to setup Apache bindings).
Do Not Start Apache. Not because anything bad will happen, but because all it will do is tell you that it cannot bind to the IP addresses and ports needed.
If you install XAMPP you’ll even get the following error during installation:
Configuring IIS to get along with Apache
Open an elevated command prompt
Type netsh
Type http
Type sho iplisten. This should return blank – this means that IIS doesn’t have a list of IPs to bind too. This also means that IIS will attempt to bind to every IP address.
Type add iplisten ipaddress=[INSERT THE IP ADDRESS YOU WANT IT TO BIND TO HERE] You should get IP address successfully added
Type sho iplisten again - It should show your IP address in the list.Rinse-repeat the above steps for each IP address you’d like IIS to bind to.
Type exit to get out of netsh
Type type netstat -an. See if you notice [YOUR ADDED IP ADDRESS]:80 in the list. If you see 0.0.0.0:80, type iisreset to restart IIS.
Finish it off
Now that IIS shouldn't be hogging all your IP addresses, you should be able to start Apache successfully.
It’s worth mentioning at this point that in order to reverse the above, you need to do the same but replace add iplisten with delete iplisten an repeat this until you’ve removed all IP addresses from the list – once there are none in the list, IIS will auto bind to all IP addresses.