How to install PHP on IIS

*Updated Recommendations - Please read the following instructions for running PHP fast and reliably*

The FASTEST and EASIEST way to install PHP on IIS is using Microsoft’s Web Platform installer.  It completely automates setting up IIS, FastCGI and the latest version of PHP from the site.  To install it, just click this button:


If you don’t have Web PI v2 installed, you will be prompted to install it.  Once installed, the tool will launch.  You can either navigate to the “Web Platform” tab and select “PHP” under “Framework and Runtimes” customize link, or close your browser, re-open to this blog and click the button again to launch the tool directly into PHP install.


For step-by-step instructions on how to install PHP on IIS6 (Windows 2003) with the new Microsoft FastCGI module, see Configuring FastCGI Extension for IIS 6.0.

For step-by-step instructions on how to install PHP on IIS7 (Windows Vista SP1 and Windows 2008) see, Using FastCGI to Host PHP Applications on IIS 7.0


My original blog post follows below and provides instructions for how to install IIS7 on Vista (RTM) using the ISAPI-based PHP.  I strongly recommend you upgrade to Vista SP1, however, and use the Using FastCGI to Host PHP Applications on IIS 7.0 instead. 


Here is a step-by-step guide for Vista RTM:

1) Download PHP from  I get the zip package because I think it is just as easy, and gives me control over setup.

2) Unzip the file to your drive.  I usually unzip it to C:\php

3) Copy the c:\php\php.ini-dist file to c:\windows\php.ini.  Tweak it as needed.

4) Install IIS7, making sure you install the ISAPI Extension component (for PHP-ISAPI - which is what I use) or the CGI component (if you prefer CGI) during IIS installation (ISAPI and CGI are *not* installed by default)

5) Open the IIS Manager (C:\windows\system32\inetsrv\inetmgr.exe

6) Click on "Handler Mappings"

(click here for full size image)

7) Click on the "Add Script Map" task on the right (in blue):

(click here for full size image)

8) Fill in the dialog box like this:

9) Pause to enjoy this handy dialog box that I had added late in RC1 just for you, then click "yes"

If you click "Yes" it will automatically register this ISAPI /CGI with the extension restriction list - the feature we added in IIS6 to prevent unauthorized executables from running on the server.  This saves time, and considering the fact that you're adding the scriptmap, it's a safe bet you want it to run. :)

10) go to your C:\inetpub\wwwroot directory and create a test.php page.  You can use the simple

<?php  phpinfo();  ?>

function to test if PHP is working correctly. 




Adddendum: several people have commented below that they are having problems getting PHP sessions to work on IIS7/Vista.  Please see this post for more information on the issue.

Another note: PHP users may wish to try out the recently announced FastCGI support from Microsoft for improved reliability and performance.  See this post for more information on the announcement, and this post for a demo of the new feature.


  • But you are still running PHP as a CGI! Why PHP runs so well with Apache is because it acts as a module and stays up. In this instance, everytime you want to run a PHP app, you have to START PHP first which takes a half a second longer to execute your scripts.

    Also, IIS still only runs on Windows and I can't shut off the GUI; even from a command line, the Windowing functionality is still using resource that the web server could be using. With Apache on Linux, I can shut off the X-server (or not even install it at all) and have more resources dedicated to my web server.

    These for me are still the ongoing issues as to why I don't use PHP on IIS. Why use it on Windows with IIS when Apache on Linux gives so much better performance??

  • Xeno - actually, if you look more closely the configuration I do above is to run PHP as an ISAPI, which runs in-process with the IIS worker process. This is essentially the same as running mod_php on apache. The biggest difference is that ISAPI requires all of the PHP extensions to be threadsafe, since IIS worker processes are multi-threaded. If this is an issue, then the CGI route is safer, since each request runs in it's own single-threaded process.

    In order to provide the best performance, and reliability of PHP on windows, I'd recommend using a fastCGI extension for IIS. There are several of them out there, including one from Zend ( which enables PHP to run quite fast on Windows. This is a feature we intend to add to IIS in the coming year. Hope this helps-

  • The pictures are not showing, which makes step 8 very hard to complete :-(

  • Lars - hmm..I'm not sure why they didn't show up for you, they are looking fine right now. Send me a message with a reply address, and I'll be happy to email instructions to you.

  • The pictures are not showing.

  • ugh, sorry guys. due to a misconfiguration the images were not working for some folks. this has been fixed

  • Maarten Balliauw has posted an alternative way to configure PHP on IIS using FastCGI which will avoid any threadsafety issues you may see with PHP extensions. See his blog post here:,php-on-iis7-rc-1-but-unsafe.htm

  • i just installed php 5 under iis7 and im getting permission denied errors whenever i try i store information in sessions any help with this would be appreciated.

  • Hey Chris - send me mail with more specifics on the error, and I'll see if I can help or at least point you in the right direction. thanks

  • I'm getting the same error as Chris it says:

    Warning: session_start() [function.session-start]: open(C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp\\sess_c74ed31a512f9111809d058373345415, O_RDWR) failed: Permission denied (13) in C:\inetpub\wwwroot\test.php on line 7

    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\inetpub\wwwroot\test.php:7) in C:\inetpub\wwwroot\test.php on line 7

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\inetpub\wwwroot\test.php:7) in C:\inetpub\wwwroot\test.php on line 7
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)

    Warning: get_browser() [function.get-browser]: browscap ini directive not set. in C:\inetpub\wwwroot\test.php on line 12

  • Do you know if this method has any inherent issues with running sessions? I'm just learning php and am working on a very simple form project that uses a session to send info from one form to a confirmation page. I noticed that I got really funky errors when I started the files with , so I assume running php in this method already starts the session????

  • Chris, I expect that to be a permissions issue. Check folder permissions on the folder "sessiondata" and "uploadtemp" in your PHP installation.

  • I've made the entire PHP directory fully open (writable by anyone) and am still getting that error. I don't have the sessiondata or uploadtemp folders in my php directory, though...??

  • Hi John - session data is stored in a temporary directory under the identity which the application is running as - by default NetworkService. &nbsp;The error message you get should specify which directory PHP is having trouble writing session data to. &nbsp;For example, in Simon&#39;s case above, the directory was: &nbsp;C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp\ &nbsp;This is the directory that the web server needs write access to. &nbsp;Also, if you could email me a test PHP script that reproduces this issue, I can try it here and give you more specifics on how to fix it. &nbsp;I tried using start-session, and it worked for me without any problems, so I suspect there is something else specific to your app that is triggering the error.&nbsp;&nbsp;you may also want to check out the documentation for session in PHP, located here:&nbsp;; using the session.save_path variable in your php.ini, you should be able to reconfigure the path for session data to something more accessible.

  • See my latest blog post for more information on how to solve the session / temporary directory issues:

  • I spent a looong time trying to figure out why I couldn't get PHP 4.4.x working with IIS 7... and I never could. Switched to PHP 5, used the same configuration steps and it worked fine.

    In researching this topic, I never came across any warning about PHP 4.4.x - so maybe this will save someone the headache. Just use PHP 5.

  • DK - here are a few tips to get PHP4 to work using the same method described above.

    1) extract to c:\php4 directory
    2) copy the php4isapi.dll from the c:\php4\sapi directory into c:\php4
    3) rename c:\php4\php.ini-dist to php.ini and copy it to c:\windows
    4) map *.php to the c:\php4\php4isapi.dll using the steps above (subtitute it for php5isapi.dll above)

    If you still have problems, try the PHP forum on, and we'll help troubleshoot.

  • I setup PHP 5 to map to the file on IIS 7 and I am able to get the php pages loaded on my localhost. But I get a blank page, any ideas?


  • Hi Bill - i followed your instructions and php seems to work; however i can't get phpInfo() to display. All i get is a blank page...
    I'm running Vista RC2...

Comments have been disabled for this content.