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.


Anonymous's picture



Anonymous's picture


THANK YOU!!! your last comment fixed my problem!! Very good thinking and analysing of problems through posts, which my lecturer couldnt solve in 10 emails. Keep it up!!

Anonymous's picture

Great Guide

This tutorial was a life saver. I attempted to install php 4 times before coming across this guide which was the first that I could follow from beginning to end. Much appreciated.

Anonymous's picture

Only one thing missing

I had to enable read access to php5isapi.dll on IUSR_. Won't everyone have to do that?

Brashquido's picture

You shouldn't have to give

You shouldn't have to give read access to the IUSR account unless the default permissions have been altered. Have you removed any of the default permissions from your PHP directory?
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Excellent Guide for Beginners Like me.

This page is an excellent guide for new programmers. After installing php5 on IIS5 I spent many days breaking my head to make it work. Many other guides didnt help. Thanks to Dominic Ryan. KEEP IT GOING

Anonymous's picture

Good Job But can you explain how to do it with Fastcgi Go live?

I think also this is a excellent guide.
But with so many expectations about using Fastcgi GoLive I would like your help about installing PHP 5.2 using FastCgi on Windows 2003

Anonymous's picture

The php code isn't executing

Dude, tks a lot for your tut. I've done everything right. I tested the installation with the "test.php" page and it is displayed correctly. The only (but a terrible headache) problem is that every single page with .php extension isn't showing.

I mean, when i try to visualize some php page, my browser only displays a blank page, and nothing it''s working. I have checked my server, and everything is fine. Can anyone helpe me?

Brashquido's picture

I'll look at putting

I'll look at putting together a FastCGI guide this week, or next week at the latest.

If you are getting blank pages, then you might like to make sure that your error reporting in php.ini is turned on. In particular make sure you have these settings;

error_reporting = E_ALL

display_errors = On

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

Anonymous's picture

HTTP 500

Hi, nice guide there, though i have some problems
On execution of any PHP file, i get the HTTP 500 error, and IE7 wont give me more details. Im using WinXP Pro, IIS5.1 and PHP 5.2. Also i got MySQL 5.0 installed. my main reason for installing PHP on my IIS server is for vBulletin, though i cant seem to run any PHP application. Mappings are correct, Environment Variables are correct too, though i installed PHP in "C:\Program Files\PHP" and i got an error to put quotes around the address when making the mapping, and instead of the normal format: C:\windows\inetserv\asp.dll, my PHP executable is in qutoes because of the between 'Program Files': "C:\Program Files\PHP\PHP5isapi.dll"
Any help will be greatly appreciated, ill be waiting for a response