How to run IIS and Apache on same machine on port 80? Here is the solution.
This article will help you to run IIS and Apache on the same machine. There are many circumstances that warrant running IIS and Apache on the same server. For example, you are running Microsoft Reporting Service on your IIS web server and your main application is running on Apache.
In this scenario, there are a few solutions available, for instance- using different ports, proxying method or if you willing to run both Apache and IIS on port 80 then you need to choose a method which requires different IP addresses (Two LAN adapters installed) for IIS and Apache on same server.Let me describe this further :-
Different IP addresses for IIS and Apache to run on port 80.
Most of us think that if we have two IP addresses on the same server then there’s no need for this article but the fact is that you have to put efforts to make this effective as you are working on Microsoft windows server. So IIS takes preference and binds it with all available IP addresses on this server.
In short, the issue is that IIS starts listening to all available IP addresses in the servers. Even if go thru IIS settings and manually assign one IP; this does not solve the issue.
I have performed this using the following:-
· Windows 2003 Server (OS on which we need to perform this task)
· Installed Windows support tools on this server. ( I have described this below in detail)
· Two LAN adapters installed.
· Set separate IP for every LAN adapter
· Each IP have mapped with a DNS
Now Let’s Start:-
Make IIS listen on a definite IP only;-
1. Start > Run> cmd.exe (open command prompt)
2. Type on command prompt C:\Documents and Settings\Administrator>httpcfg set iplisten -i XXX.XX.XXX.X
Note :- XXX.XX.XXX.X is the IP address on which you want IIS to listen.
2.1. If the message “’httpcfg‘ is not recognized as an internal or external command, operable program or batch file.” appears that means Windows support tools is not installed. Here is the link that will help you http://www.microsoft.com/downloads/details.aspx?FamilyID=96a35011-fd83-419d-939b-9a772ea2df90&displaylang=en
2.2. If the message “ HttpSetServiceConfiguration completed with 0.” will appear then say cheese, for it works. Now let’s confirm this change by running “C:\Documents and Settings\Administrator>httpcfg query iplisten” you will receive IP : XXX.XX.XXX.X
3. Now let’s confirm this change by running “C:\Documents and Settings\Administrator>httpcfg query iplisten” you will receive IP : XXX.XX.XXX.X
4. Now you need to restart http service by performing command.
4. 1. C:\Documents and Settings\Administrator>net stop http /y
Note: – I received the following messages:-
The following services are dependent on the HTTP service.
Stopping the HTTP service will also stop these services.
World Wide Web Publishing Service
The World Wide Web Publishing Service service is stopping..
The World Wide Web Publishing Service service was stopped successfully.
The HTTP SSL service is stopping.
The HTTP SSL service was stopped successfully.
The HTTP service was stopped successfully.
4. 2. C:\Documents and Settings\Administrator> net start w3svc
Note: – I received the following messages:-
The World Wide Web Publishing Service service is starting.
The World Wide Web Publishing Service service was started successfully.
Now you need to make change in Apache configuration file
5. Edit httpd.conf, set: Listen ZZZ.ZZZ.ZZ.Z:80
Note :- ZZZ.ZZZ.ZZ.Z is the IP address on which you want Apache to listen.
6. Now you need to restart Apache. If you are running Apache as service,you can use “net stop apache” And after that: “net start apache”
That’s it!! It’s done!!
The changes will replicated to the following location of registry.
- Click Start, click Run, type regedit, and then click OK.
- In Registry Editor, locate the following registry subkey:
Running Apache and IIS 6 together on the same server
We have a Windows Small Business Server at work, which we wanted to install Subversion onto. We therefore wanted to run Apache on the same server. However, IIS is also installed on the same machine for Small Business Server purposes so I couldn’t just remove IIS.
I had added multiple IP addresses to the server so that IIS could have one and Apache could have another (so they could both run on port 80). However, I ran into the problem that IIS was taking control of all IP addresses on port 80 and so Apache wouldn’t start. It seems that IIS 6.0 has a “feature” called Socket Pooling that claims all ports for all loaded IP address (even if not configured in IIS) – nice! So IIS had control of the port 80 on the IP address I had assigned to Apache.
Do not fear – there is a workaround:
- Extract the httpcfg.exe utility from the support tools area on the Win2003 CD.
- stop all IIS services: net stop http /y
- have IIS listen only on the IP address I’d designated for IIS: httpcfg set iplisten -i 192.168.1.253
- make sure: httpcfg query iplisten (the ip’s listed are the only ip addresses that IIS will be listening on and no other)
- restart IIS Services: net start w3svc
- start Apache service
You’ll then find that Apache and IIS will then play nicely together and run on the correct ports on the correct IP addresses. Woo hoo!