Forget What Your Mother Told You, IIS and Apache can be Friends
Join the DZone community and get the full member experience.Join For Free
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
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 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 addedtype 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.
Opinions expressed by DZone contributors are their own.