Apache and IIS, Side by Side

Usually, there is only a need for Apache or for Internet Information Services (IIS), but not both. However, when one does development that involve both servers - e.g. PHP work on Apache, and ASP.NET on IIS - it may be necessary to have both running on one development PC. But there is a catch. Normally, they can’t both run at the same time.

(I’m writing this in part because I always forget how this is done when setting up a new system, and this way will know where I can quickly find the details)

Granted, one could shut down on server and start the other when necessary, but that’s a pain to have to remember, and I always manage to forget. But there is a way to have them running side by side at the same time.

The conflict here is that both Apache and IIS by default use the same port, port 80, which is the default for web servers. They can’t both use the same port at the same time. The solution: tell one of the servers to use a different port.

Apache seems to be easier to change, since the process is more involved when changing the port for IIS. So I’ll show how to tell Apache to use a different port.

  1. Locate your Apache installation. I usually install Apache at C:\Apache, but yours may be different.
  2. Open the httpd.conf, in the conf folder, with a plain text editor such as Notepad.
  3. Find the line that starts with Listen. Mine was on line 120. To find it faster, you could try searching for Listen 80.
  4. Change the 80 to a different number of your liking… It’s a good idea to use something similar, such as 81 or 8080. I use 81, myself.
  5. Search for ServerName (mine is on line 212), and change the port at the end to the same value you used in the previous step.
  6. Go to the bottom of the file, and add the following code:
    <virtualhost 127.0.0.1:81>
    DocumentRoot "c:/public_html/"
    ServerName localhost:81
    </virtualhost>

    Modify the DocumentRoot and ServerName to your liking. Replace 81 with whichever port you selected in step 4. For my local test machine, I like to use localhost. Although I could just as well use projectName:81, where projectName is some web project I am working on.

  7. Save and close this file.
  8. Restart Apache.

Now open a web browser, and go to whatever address you entered for ServerName. You should now be able to view your Apache localhost at this URL. And you can have your projects running in both IIS and Apache without the servers conflicting with each other.

Make a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>