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


Just wanted to say thanks for taking the time to write this tutorial. I installed php and mysql with apache before, but it's been a while, and I'd never worked with IIS before until recently. This was a great tutorial to get me up and running quickly, everything worked like a charm.

Anonymous's picture

http 500 error

I followed steps above to install PHP 5.2.3 for IIS 5.1. But when I test it, I got HTTP 500 error. Any solution?

Brashquido's picture

A 500 error could be caused

A 500 error could be caused by a few things. Most immediate one that comes to mind as I had to deal with it just the other day is the fastcgi.impersonate setting in your php.ini file is set to 1.

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

Anonymous's picture

Uninstall PHP 5

Great article. I had PHP 4 installed, but the PEAR option was not installed. So I thought to Uninstall and install a version that had PEAR. Everything was working fine PHP4. I uninstalled, reboot, and then reinstall PHP5 using the MSI installer. However, my PHP webpages came back with an 404 error.

Whats the best way to uninstall and remove all PHP related files from my Win2003 server? and to a complete reinstall following your instruction.


Brashquido's picture

Might be worth double

Might be worth double checking that you enabled a web service extension for PHP5 before we look at removing all things PHP from your system. Without knowing how PHP has been installed on your system there is very little chance of me being able to tell you exactly where and what to look for, but I can give you a general guide;

1) Ensure paths referencing PHP are removed from the PATH variable
2) Delete all PHP files
3) Check your windows system directories for PHP files which are sometimes copied over from the PHP directory when the PHP paths are not set correctly during setup.
4) Delete all PHP web service extensions from IIS
5) Delete all PHP application mappings from IIS

That should about cover all the obvious ones I can think of for now...

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

Anonymous's picture

a perfect worl a perfect guide

I NEVER write comments on these sites. For your guide I had to. VERY good job. 7th instruction set. Worked like a CHARM

Anonymous's picture

Very strange PHP session problem on IIS5, IIS6

Hi Ryan,
i installed PHP on my IIS5 (XP Pro), IIS6 ( win2k3 server SP2 R2) , everything works fine, except PHP session.
my server IP is
< ?
if i open this test.php like this: http://localhost/myweb/test.php, no error occur, but if i open the test.php like this:, it says:

Warning: session_start() [function.session-start]: open(C:\WINDOWS\TEMP\\sess_ii5515gqj838mhpugm5lr267e2, O_RDWR) failed: Permission denied (13) in C:\MyWeb\test.php on line 2

Warning: Unknown: open(C:\WINDOWS\TEMP\\sess_ii5515gqj838mhpugm5lr267e2, O_RDWR) failed: Permission denied (13) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0

any idear?


Brashquido's picture

Hi Jaive, Can you open your

Hi Jaive,

Can you open your php.ini file and find the line with the session.save_path directive in it? Once you've found it post back here with the entire line.
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

BeachBoy's picture

Newbie questions

Hello Dominic,

I have a few questions as a newbie using IIS and PHP 5.2.x for you. I'm just getting started using IIS as a subdomain of my site (, mostly because my hosting provider is running the main site on Linux w/ Apache, PHP 4.3.1, and MySQL 4/5. I wanted a testbed for Drupal 5.2, and I've already got a SSL certificate installed (from CACert). My questions for you are as follows:

1. If I install PHP 5 per your instructions in the how-to, can I use a preconfigured PHP.ini file (for example, the one created using the IIS-AID installer after I remove the PHP 4 install)?

2. Do you recommend using any other tools for the testbed server besides PHP and MySQL? If so, are any of them open-source or free?

3. Do you have any other tips for a newbie wishing to use Drupal on IIS?

Please feel free to contact me when you can. Thanks in advance.

~ BeachBoy

Brashquido's picture

Hi BeachBoy, 1) Mostly, but

Hi BeachBoy,

1) Mostly, but there are a few differences between PHP 4 and 5. For instance the MySQL client is loaded automatically in PHP4, but loaded separately as a PHP extension in PHP5. There also might be issues with paths and things. It could be done, but I'd think there would be fewer issues with just altering the existing PHP5 ini file.

2) Depends totally on what you want to do. PHP is by far the most popular open source scripting language around at the moment, and as such most open source web apps utilize this language. About the only other "must have" I'd say you need there is Perl (check out Activestate), and maybe if you're feeling like it RoR. Obviously you could also look into .NET for running web apps such as Dot Net Nuke.

3) Make sure you backup and just spend time with it. Only other Drupal specific thing I'd recommend you look at is Clean URL's (such as use on this site). There are presently only a few offerings for IIS that enable you to manipulate URLS to create this effect. I'd recommend having a look at Helicon ISAPI Rewrite Lite which is free, and then check out my guide in the "how to guides" section.

Let me know if I can be of any more help.

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