Installing PHP 5 on IIS in 5 simple steps


Set the PHP Application Mapping in IIS

Before IIS will parse PHP scripts, you must first create an application mapping for PHP. This application mapping basically tells IIS what ISAPI dll, or CGI executable to use to process files of a certain file extension (in this case .php). There are two ways in which we can do this, via the command line or via the IIS MMC snap in. I'm going to show you how to do both.

As this is a universal PHP installation guide for IIS 5.0, 5.1 and 6.0 there are limited universal ways in which to add the PHP application mapping via the command line. What ever you do though do not use the adsutil.vbs script to try and add you PHP application mapping, at least not without understanding it's limitations. When you add/delete an application mapping with adsutil.vbs there is no way you can add/delete a single item at a time. So by using adsutil.vbs to add an application mapping you will effectively delete every other mapping at that level. However, what you can do is use David Wang's awesome chglist.vbs script to add the PHP application mapping without effecting existing mappings. You can download this script from David's old blog or from the bottom of this page. Once you have saved the script, simply open a command window and change into the directory that contains your script and type this in;

chglist.vbs W3SVC/ScriptMaps "" ".php,D:\PHP\php5isapi.dll,5" /INSERT /COMMIT

This will add the PHP ISAPI script map to the root of the IIS metabase, and any sites created after adding this script will automatically inherit it. If you want to add the PHP application mapping to a specific website then you will need to modify the W3SVC/ScriptMaps section of the command to suite. If none of this makes sense at all, don't worry because all this can be done using the GUI as well which we will cover now.

  • Open the IIS MMC and right click on the Web Sites container (or click on any specific website you wish to add PHP to) and select the properties menu item

figure 6

  • Once the Web Sites Properties window opens select the Home Directory tab and click the Configuration button as shown below in figure 7.

figure 7

  • This will bring you to the Application Configuration window. Click the Add button at the bottom to add the PHP application mapping as shown below in figure 8.

figure 8

  • In the Extension field enter .php and then click on the browse button in the top right and select the php5isapi.dll file from inside you PHP installation directory (e.g D:\PHP). The default is to accept all verbs, but if you wish you can limit the verbs to tighten security for you PHP application mapping. Ensure that the Script engine and Check that file exists options as ticked and then press ok until you exit the properties windows.

figure 9

That is it, IIS should now be configured to serve PHP content. There is one exception though and that is if you are using IIS 6 then you will also need to configure a Web Extension, so if you are using IIS 5.0 or 5.1 you can proceed onto the next section. You can set the Web extension via command line using iisext.vbs or via the Gui. Using the iisext.vbs at the command prompt you'll need to type in this, but be sure to change the path to php5isapi.dll to suit your environment ;

iisext.vbs /AddFile D:\php\php5isapi.dll 1 PHP5ISAPI 1 "PHP 5 ISAPI"

To add the extension via the GUI, read on;

  • Open the IIS MMC and expand the server tree. Right click on the Web Service Extensions option and select the Add a new Web service extension option.

figure 10

  • In the Extension name field put in a descriptive name, such as PHP 5 ISAPI as shown below in figure 11. Make sure the Set extension status to Allowed option is checked and then click the Add button.

figure 11

  • In the Add file window click the Browse button and navigate to your PHP installation directory and select the php5isapi.dll file as shown below in figure 12. Then click the ok button until you exit back into the IIS MMC.

figure 12

All done, now your IIS 6 web server is all set to serve PHP content.


Brashquido's picture

You have definitely

You have definitely uncommented php_mysql.dll in your php.ini file? If so, then have a look at the path for the "Loaded Configuration File" value near the top of your phpinfo page. Is this correct?

Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Excellent Guide

Thanks a lot for such a excellent and elaborative guide. Really helpful.


Anonymous's picture

Problem installing on IIS 7

Hi, and first thank you for this nice guide.

However I have problems installing on IIS 7 as the interface is really different from previous versions and I am far from beeing a specialist in configuring IIS.

I did evrything you said (at least I think so) but I have a 404.17 - Not found error when calling the phpinfo.php page.

Detail error should be something like "aked content seems to be a script and won't be handled by the static file manager".
Sorry if that message seems weird but it is a translation as my system is in French.

Just for information the web site works correctly if I call an .htm or .aspx(.net) file.

If you have any hint...

Anonymous's picture

installed aid to server 2008 with iis 7

and got problems.
well, before I could run php for all sites. PHP had been installed manually form php distributive. but I couldn't run smarty.
Today I thought to implement Aid tool. First removed php and installed tool. The first strange thing I sat that it said me that Fast-CGI is not installed. It was! And offered use ISAPI. ok. Asked to direct all php sites. Directed.
In result now I can't run any site having error:
HTTP Error 404.2 - Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.
•No handler mapping for this request was found. A feature may have to be installed.
•The Web service extension for the requested resource is not enabled on the server.
•The mapping for the extension points to the incorrect location.
•The extension was misspelled in the browser or the Web server.

Checked according these directions. Everything looks ok but still nothing works. What to do now?

Help please!

Anonymous's picture

Almost working

First of all, it's nice to see some dedicated person sharing his knowledge with the community. Great work.

Now with my problem.
I am using Windows XP Pro SP3
IIS 5.1 and PHP

I got the PHPInfo.php working fine.
But when I call a .php page from a button, only the code of the .php appears. I have been working for the last 2 days on this problem, but can't seem to find the solution. I checked, double checked and triple checked everything, uninstall IIS and PHP. I did the reinstall to get the same result.

I also must say that I tried to install php with the Apache 2.2 before but had similar problem. The only difference is that it prompted me to download or save the file instead.

Any thought about this ?
Thank you for reading this.


Anonymous's picture

Almost working part 2

Hello again,

Well I think I have the solution to my problem. Would like your advice if it is normal.

When I access my file like this (http://localhost/Exercice1PHP.html) and click on the cmd button everything works fine but when the page is accessed like this (C:\Inetpub\wwwroot\Exercice1PHP.html)this is when I get this:

Le Garage de Bob - Résultats de la commande

Le garage de Bob

Résultats de la commande

echo '

Commande traitée.';

as a result.

So, is it right to say that when working on the local server, the address always has to start with HTTP://localhost/ or HTTP:// ?

Hope to hear from you soon
Best regards,


Brashquido's picture

Hi Pierre, This is actually

Hi Pierre,

This is actually quite a common issue. PHP is an interpreted script, meaning it must be proceesed by either PHP CLI or a webserver configured to process PHP content into a format that can be rendered by your browser. When you access your PHP scripts locally using http://localhost or you are invoking your locally installed webserver to proccess the requested content. When you try and access these scripts directly (i.e C:\Inetpub\wwwroot\Exercice1PHP.html) then you bypass your webserver and the PHP script is not executed.
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture


So if I want to work on more than one project, how do I manage my files. I tried to create directories, but the page pages won't show at all. I have the HTTP 404 error(can't findthe page). Exemple http://localhost/PHP/chapitre2/orderform.html

But when I but the page directly in the wwwroot folder like this http://localhost/orderform.html it is working fine.

Is there a way I can use so I don't put all my files in the same directory?

Thanks again for your assistance. greatly appreciated


Brashquido's picture

404 could mean permissions

WHen you've confirmed that the files are definately there and are sure the path is correct, then a 404 error usually translates to there being a dile permissions issue. Ensure all you web files have at least NTFS read permissions to your IIS user account (usually IUSR_COMPUTERNAME).

Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

WHen you've confirmed that

WHen you've confirmed that the files are definately there and are sure the path is correct, then a 404 error usually translates to there being a dile permissions issue. Ensure all you web files have at least NTFS read permissions to your IIS user account (usually IUSR_COMPUTERNAME).

I have tried and couldn't get it working. Any other ideas ?
Would the fact that I have Visual Studio.Net 2008 installed be the cause as it also use IIS.