Run you own web server using PHP / ASP.NET on IIS7 [Part #1]

These tutorials aims basically to target PHP and beginner ASP.NET developers to show them how to configure, run and make their IIS7 web server serving websites on Internet from their home machines. It's also intended to fill the gap between PHP developers and the non open source products out there, especially the IIS server which a lot of them are not aware of. Also ASP.NET developers will benefit from these tutorials too, because configuring the server affect any web platform running on that server.

Part #1 will be a quick view of how to make IIS7 run your website locally and how to access it from internet. Most of the time, when developing web application, we encounter a lot of problems like timeout requests, malformed HTTP headers and of course execution time and such that we can't test once we develop on a local server. So configuring our machine to be a webhost will be the first step that we will take.

Also, you can use your own web server for testing purposes, developers usually send a copy of their web applications to friends to test it, which is just a bad choice in all sorts of considerations, the best is to access one version of your website running on your own machine like a real website with a special domain name.

IIS7? The "what" and the "why"

IIS stands for Internet Information Service and it's Microsoft’s web server running on windows platforms. IIS7 is the latest version and the most secure, fast, reliable and robust; it ships with Windows Vista, Windows 7 and Windows 2008 Server by default with some limitations according to your windows edition.

I can just say: it is more than great; you want to find out more about it here : or

Installing and running IIS7

IIS7 is installed by default on Windows 2008 and some Windows 7 / Vista versions, check the Administrative tools in the control panel to see if there is the IIS manager or not, In case it's not installed, just few clicks will bring it up, follow the tips here :

To run IIS7 : Start > Control Panel > Administrate Tools > IIS Manager, notice that you must have administrative privileges to do so.


This is the IIS manager, where you can configure all the aspects of the server, if you used IIS6 or 5 before, you will find this a little different from the old ones. As you can see there are dozens of settings from Modules, to CGI and port bindings to a lot of other stuff that we will walk through in the next part.


To make sure everything was configured correctly, go to or http://localhost/ on your browser.


Making IIS7 available on the web

The easiest way to do so is to find your IP address, use for example, and navigate to /">http://<you-ip>/. Chances that you won't get access to your server are very high, first because you may be using a router which blocks entering requests, or your firewall is blocking every request coming from internet.

Configuring your router

The next step is to configure your router to translate the port 80 (http) to your web server in order to handle it, just head to your router configuration page, look for the port translation option and map the port 80 (TCP) to your machines LOCAL IP address with the port 80 also (we will talk about port binding on IIS in the next parts).


That's it, nothing more, now typing your own IP address will give you the IIS7 welcome homepage.

Giving your server a domain name

You may prefer accessing your server with a domain name rather than using your IP address (which is a problem as we will see in the following section). You can use your own domain name to make it point to your IP address, or you can use a free, fast, lightweight service aimed for such testing and not persistent cases.

I used for this, they have a good DNS redirection services and it's for free, just create an account, choose your sub domain and point it to you IP, for example "" like in the following picture :


Now you can access you web server using that domain name which is better than typing the IP address.

Dynamic IP, The domain name is not pointing to your server anymore!

If your provider assigns a different IP each time to your router then the above method will just break because the domain name will always point to the old IP address. There are a lot of solutions for this, but the best one is to use DynDNS if your router supports this by default.

DynDNS is almost the same thing as the previous service except that it points to the IP the router indicates and updates each time it changes. Once you create your account on DynDNS (Also free, don't worry), enter these details on your router DynDNS configuration section, and you are done:



Debugging, security and everything else

I am sure that since you are a web developer, you are aware of security and privacy risks, like tracing your IP to know your location, or hacking, brute forcing your server. But if you are aware enough nothing of that will happen, and since this is just a startup server to test with some of your friends, an application like this wouldn’t be a problem after all.

At the end I would like to mention how debugging under the .NET framework and IIS works to give more security options to developers. If you have an error in your website for example, running it locally with show you more details about the error and the configuration of the server, but requesting the web application from outside will just give a simple message indicating the HTTP status of the error like in the following pictures. This is a very useful feature in web development security.



The next tutorial will be about: how to configure IIS7 and run PHP on top of it.

[Bonus] This is how did I test my IIS from a Windows XP machine connecting to a public wifi, pretty nice isn't it :)

2009-09-21 23.38.52

Bookmark the permalink. RSS feed for this post.

comments powered by Disqus

Swedish Greys - a WordPress theme from Nordic Themepark. Converted by