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

php.ini - missing line causes file download prompt and so on...

As far as I can see, the only thing that's missing is another change to the php.ini file regarding cgi.force_redirect setting.

The value MUST be set to zero. The php.ini file reads:

"cgi.force_redirect is necessary to provide security running PHP as a CGI under most web servers. Left undefined, PHP turns this on by default. You can turn it off here AT YOUR OWN RISK
**You CAN safely turn this off for IIS, in fact, you MUST.**"

Before I changed that setting, I had the same problem as a lot of people writing comments here: prompt for file download instead of displaying the page when using a web browser to connect to http://localhost.

I went through a couple of guides and none of them worked for my system. I am using Win XP with IIS 5.1 and I've tried to follow the manual installation steps described on the PHP site but it didn't work for me.

I just couldn't get FastCGI to work with PHP 5.3.3 no matter how hard I tried. I did everything by the book several times, nothing... When I chose php-cgi.exe for the executable - it worked but I wasn't sure if that's the way to go, so I decided to try it with your instructions.

Seems to be working fine, except for that initial

Anonymous's picture

how to put the file in website

i created phpinfo.php file using notepad.But how to place it in website and test using web browser.


Brashquido's picture


Hi John,

Usually you'd use something like FTP to upload your files to your webserver. Ultimatley it depends on how you connect to your server though. I'd recommend contacting your host to determine which method to use.

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

Anonymous's picture

IIS 5.1 being prompted to download .php

I spent a couple of days trying to get PHP 5.3 and FastCGI working with IIS 5.1. Symptom: it would hang, it would be blank, it would prompt for download depending on how I tinkered. The catch? I was doing the Mapping (.php to fcgiext.dll) correctly in IIS except applying it to the Web Sites folder instead of Default Web Site which is one below that in the IIS listing. I gather Default Web Site is the one that corresponds to where I have phpinfo.php test file with and I had been assuming subdirectories inherit the mappings automatically. Not so. I also had a problem with the OK button being grayed out when browsing for the mapping dll - and found you just need to click your mouse in the text box where the path is.

Anonymous's picture

Prompted to download the phpinfo.php file

I was having this problem with PHP Version 5.2.17, all I had to do was change the configuration and setting the php5isapi.dll on page 3 for each of my IIS website virtual directories that I have already made before installing PHP. (remember to restart IIS afterwards)

Thanks a great tutorial on PHP...

Anonymous's picture

Many thanks, Fantastic post.

Many thanks, Fantastic post. The best I have seen regarding installing and configuring PHP and MySQL for IIS.
I have installed everything as your instructions and it is working perfectly.

Although I do have an issue with OWA and activesync that you may be able to help with.

I am using SBS2003 on the IIS default web site.

Before installing Wordpress, PHP and MySQL, OWA and activesync were working fine. After installing Wordpress, PHP and MySQL, both OWA and activesync will not accept the login credentials. Index.php and PHP are affecting the default home documents of the default web site, everything is run through index.php.

To problem solve the issue, I have created two Home Directory folders for the default web site, one with the default setup (including default.htm, default.asp, index.htm, default.aspx) and the other with default setup AND the wordpress .php files. When I set the local path of the home directory to the folder that contains the .php files, our PHP web site functions perfectly BUT the OWA and activesync will not accept the login credentials. If I change the home directory to the folder that does NOT contains the .php files, OWA and activesync both function perfectly, but obviously our PHP web site does not function tech talks.

Any suggestions?????

Anonymous's picture

Top man

Great guide, thx a lot.

Anonymous's picture


This was a good guide to have PHP up and running on IIS, but I have done this all, but unable to get the PHP page to work. It shows the error as
"The page cannot be displayed
There is a problem with a program on the page you are trying to reach, and the page cannot be displayed."

I had this PHP running previously, until I re-installed the OS(XP), can't get this to work. I installed PHP, configured env variables, set the mapping to 'php5isapi.dll', set all the paths in php.ini, but no luck as well as no sensible errors. Can't decide, where to start searching. It is as if the PHP.ini is not being recognized, even though it is present only in 'wwwroot'. Tried mapping to 'php-cgi.exe', and force redirect to 0; still no go.

Need help or what am I doing wrong ?

Anonymous's picture


This is to add to my last post, where I was not able to get PHP running and got the error as 'The page cannot be displayed'.

This turns out to be execute permissions to be set in IIS. Somehow this keeps reverting back to 'none' when a php page is accessed, leading to the error. I guess if you have done everything right, checking the IIS configuration would definitely save a lot of hair and time rather than tampering with the PHP installation.

Also, the php.ini path seems to be bouncing around between C:/Windows and the installation path of the PHP. Not sure what is causing this though...

Brashquido's picture

IIS applications and/or multiple PHP installs?

Sounds like a bit of a headache. This sort of behaviour can be caused by a few things, my guess would be something like there being multiple PHP mappings in IIS as well as possibly multiple instances of PHP. Honestly you can spend hours trying to fault find these sorts of errors, and being a Windows 2000 server I'm guessing this is not a new install. My advice would be to start from scratch by doing a full uninstall of PHP on IIS, and in doing so you are ensuring your IIS environment is as clean as you can realistcally get it before installing PHP.

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