HOWTO: Install and run PHP on IIS7


Hi all,

I have trouble to configure PHP 5 (CGI mode) in IIS 7 on Vista 5308...

What I did:
- Download and unpack PHP
- set user permission to PHP folder AND script folder (IIS_IUSRS and Internet Guest Account)
- in IIS Manager: Added pages in Default documents
- Added in "ISAPI and GCI Restrictions": Allowed PHP  group ID PHP path c:\php\php-cgi.exe
- Added in "Global Modules" PHP as integratedmode path c:\php\php-cgi.exe
- Added in "Handler" PHP to map *.php,*.php3 type:File path c:\php\php-cgi.exe all verb handler:cgimodule
- Added in "module": PHP code:c:\php\php-cgi.exe module:native entry:local


Unfortunately, at this point in the beta cycle, IIS7 configuration failures are still cryptic, so you basically need to really know what you are configuring. However, most things are conceptually the same as prior IIS versions - just maybe named/organized or configured differently.

For many reasons, I do not use the UI nor give instructions for the UI (except if explicitly talking about a UI-behavior), so all my instructions directly manipulate the necessary .config files with the right values to generate the desired behavior.

  • The UI is still under development and can change from build to build, including introduce bugs. A UI bug should not prevent you from using server features.
  • The server behavior (and hence configuration) rarely changes. The UI surrounding it may change in response to concepts/feedback, so UI-based instructions can be out-of-date, especially during beta.
  • I want to illustrate how to configure and use IIS, not how to use the UI to generate the necessary configuration.

In your case, you basically chose to configure all possible locations, but that is not all correct and thus IIS7 will mysteriously fail. In particular, configuring PHP as a "Global Module" or "Module" is incorrect.


This is all you should do (and why):

  1. Install PHP into %SYSTEMDRIVE%\Inetpub\PHP (I want to easily inherit any IIS7-related ACLs)
  2. Download and unpack PHP into %SYSTEMDRIVE%\Inetpub\PHP (For this example, I chose the latest currently available build, PHP 5.1.2 ZIP package, from )
  3. Use the recommended PHP.INI-Recommended INI file inside the PHP directory (or whatever PHP configuration you need)
  4. Configure a Handler for *.php using %SYSTEMDRIVE%\Inetpub\PHP\PHP5ISAPI.DLL or %SYSTEMDRIVE%\Inetpub\PHP\PHP-CGI.EXE (I prefer the ISAPI version on IIS) and order the Handler AHEAD of the StaticFile Handler
  5. Configure an ISAPI and CGI Restrictions entry to enable the added Handler for PHP

This is all you need to do. Conceptually, it is not any different than prior IIS versions, like IIS6, and the necessary data is pretty much the same. The only difference is that you are configuring a Handler instead of an Application Mapping. This is because we have reconciled the IIS Application Mapping with the ASP.Net httpHandlers (as well as many other things, such as ISAPI Filters and httpModules) to form the new IIS7 Integrated Pipeline. The new unified section is called "handlers".

The Details

The astute Reader should note that it is important to place the PHP Handler ahead of the StaticFile Handler. Why?

Unlike the IIS Application Mapping list, which is unordered, the Handlers list is ordered. This means:

  • For Application Mappings prior to IIS7, we chose to have arbitrary behavior of wildcard application mappings always run first to handle a request, and if unhandled, then the first Application mapping with a matching extension is executed).
  • For Handlers in IIS7, we chose to have first-match (of extension/verb) wins. This gives user complete control over Handler resolution order; no arbitrary ordering imposed by IIS core.

In other words, you can configure IIS7 Handlers to act like pre-IIS7 Application Mappings by doing the following (conceptual). Note that IIS6 hardcodes the ordering of WildcardApplicationMappings and StaticFileModule to be first and last, respectively... while IIS7 allows you to order the Handlers however you want:

    <add modules="WildcardApplicationMapping1" verb="*" path="*" />
    <add modules="WildcardApplicationMapping2" verb="*" path="*" />
    <add modules="IsapiModule" verb="GET,HEAD,POST" path="*.asp" />
    <add modules="StaticFileModule" verb="*" path="*" />

Of course, with power comes responsibility. With such a flexible system, it means that the StaticFile Handler, which maps to all extensions and all verbs, must be configured last so that it is the Handler of last resort after all other Handlers fail to match. This means that any added  handlers must be ahead of the "wildcard" handlers since otherwise the wildcard handler will get picked first.

Instructions (Automation)

Ok, suppose the Instructions weren't clear enough. Here is the commandline version of the above instructions. 🙂

ECHO Extract PHP files from ZIP archive into %SYSTEMDRIVE%\Inetpub\PHP
PUSHD %SYSTEMROOT%\System32\inetsrv
APPCMD SET CONFIG -section:handlers -+[name='PHP',path='*.php',verb='GET,HEAD,POST',modules='IsapiModule',scriptProcessor='%SYSTEMDRIVE%\Inetpub\PHP\php5isapi.dll',resourceType='File']
APPCMD SET CONFIG -section:isapiCgiRestriction -+[path='%SYSTEMDRIVE%\Inetpub\PHP\php5isapi.dll',allowed='true',groupId='PHP',description='PHP5']

Yes, I am using the new APPCMD commandline tool for manipulating IIS7 configuration to make scriptable changes. You can view it as the IIS7 uber-replacement for adsutil.vbs and all of the IIS6 commandline tools. Bear with the cryptic syntax for the moment - it is really quite handy once you get past the syntax (especially the syntax for collection manipulation - I can spend a blog entry just talking about it alone 😉 ).


The above instructions are all the IIS-specific steps necessary to get PHP to work on IIS7. I was able to run a PHP page containing <?php phpinfo();?> after making just those changes on top of a default IIS7 installation. If you still have problems, it is most likely coming from PHP itself.

For example, php-cgi.exe does not seem to work because its CGI output is missing the Status: field as required by CGI 1.1 specification.

[Modified 4-4-2006] php-cgi.exe does work on IIS7. You need to modify PHP.INI to have the line:

cgi.force_redirect = 0

If you do not do this modification, PHP-CGI.EXE outputs a security warning response without proper response headers, which causes IIS to return a 502 Bad Gateway. Strangely, running PHP-CGI.EXE from the commandline does not generate this error - I guess using NPH CGI is the only way to debug PHP, because running it from the commandline is not 100% indicative of web-server Runtime behavior.

[Modified 6-14-2006] Removed the following lines of batch script to work-around of APPCMD manipulation of StaticFile module since the bug got fixed.

APPCMD SET CONFIG -section:handlers --[name='StaticFile',path='*',verb='*']
APPCMD SET CONFIG -section:handlers -+[name='StaticFile',path='*',verb='*',modules='StaticFileModule,DefaultDocumentModule,DirectoryListingModule',resourceType='Either',requireAccess='Read']

[Modified 6-24-2006] Linked to newer instructions here.


Comments (67)
  1. CG says:

    Oh, thanks a lot!

  2. Corey S says:

    I followed the steps set out above and ran into a brick wall in the command prompt. (I’m guessing this is simply a security permission setting in Vista itself I need to change)

    On entering "APPCMD SET CONFIG -section:handlers –[name=’StaticFile’,path=’*’,verb=’*’]" I get the following error:

    "ERROR ( message:Configuration error

    Filename: \?C:Windowssystem32inetsrvapplicationHost.config

    Line Number: 0

    Description: Cannot read configuration file )"

    The file exists and read permissions are set for all user types, so I’m stumped. If it said it couldn’t write to the file I could understand it.

    Am I an idiot, or did I make a simple mistake?

  3. steve says:

    i ran your recommended script as a batch file, it succeeded and the changes showed up in the iis manager.  however, i buit the same index.php with <?php phpinfo(); ?> and it returns the following:

    Server Error in ‘/’ Application.


    Index was outside the bounds of the array.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

    Stack Trace:

    [IndexOutOfRangeException: Index was outside the bounds of the array.]

      System.Web.HttpApplication.AddEventMapping(String moduleName, RequestNotification requestNotification, Boolean isPostNotification, IExecutionStep step) +166

      System.Web.PipelineStepManager.BuildSteps(WaitCallback stepCallback) +81

      System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1191

      System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +348

      System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +163

      System.Web.Hosting.PipelineRuntime.ExecuteStateHandler(IntPtr& managedRequestContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) +657


    Version Information: Microsoft .NET Framework Version:2.0.50727.88; ASP.NET Version:2.0.50727.88

    any advice?

  4. steve says:

    btw, corey, i had the same problem.  i created the directory, extracted php, copied over the recommended into php.ini, then made a file called php.bat that contained the rest of david’s script:

    PUSHD %SYSTEMROOT%System32inetsrv

    APPCMD SET CONFIG -section:handlers –[name=’StaticFile’,path=’*’,verb=’*’]

    APPCMD SET CONFIG -section:handlers -+[name=’PHP’,path=’*.php’,verb=’GET,HEAD,POST’,modules=’IsapiModule’,scriptProcessor=’%SYSTEMDRIVE%InetpubPHPphp5isapi.dll’,resourceType=’File’]

    APPCMD SET CONFIG -section:handlers -+[name=’StaticFile’,path=’*’,verb=’*’,modules=’StaticFileModule,DefaultDocumentModule,DirectoryListingModule’,resourceType=’Either’,requireAccess=’Read’]

    APPCMD SET CONFIG -section:isapiCgiRestriction -+[path=’%SYSTEMDRIVE%InetpubPHPphp5isapi.dll’,allowed=’true’,groupId=’PHP’,description=’PHP5′]


    i saved that, right clicked it and chose run as adminstrator

  5. Jamie says:

    I have followed the install guide and still receive the following:

    Server Error in ‘Default Web Site’ Application.


    HTTP Error 404.4 – Not Found

    Description: The resource you are looking for does not have a module or handler associated with it. It cannot be handled and served.

    Error Code: 0x00000000

    Notification: ExecuteRequestHandler

    Module: IIS Web Core

    Requested URL: http://localhost:80/test.php

    Physical Path: C:inetpubwwwroottest.php

    Logon User: Anonymous

    Logon Method: Anonymous

    Handler: PHP


    The file extension for the requested URL does not have a module or handler configured to execute the request on the IIS server.

  6. David.Wang says:

    Corey – by default, you login as a limited rights user on Vista, which cannot change applicationHost.config from commandline tools like APPCMD.EXE or even notepad.

    You have to run the commands or make modifications using the privileged Administrator account, as Steve describes.


  7. David.Wang says:

    Steve – Not certain about your issue. I did not encounter any problems running <?php phpinfo(); ?> after following the instructions.

    My guess is that you had something additional ASP.Net httpModule/httpHandlers enabled, or non-default modules/handlers list. Misconfigurations in there can cause non-obvious failures.

    My suggestion is that after you install IIS7 that you make a backup of applicationHost.config so that you can muck around with IIS7 configuration however you want, and if you screw up, just copy the backup and be back in business.


  8. David.Wang says:

    Jaime – I just updated the blog entry to address your issue.

    Since I made the blog entry in April, which included a workaround for a known IIS7 bug, the bug was fixed and invalidated the work-around.

    So, I removed the work-around, and the shortened instructions now work.

    Basically, as I indicated in the blog entry, ordering between handlers matter when it comes to correct functionality. The bug affected ordering; the work-around restored the ordering; the bug fix changed ordering again, invalidating the work-around.


  9. Ken Ford says:

    OK I have PHP installed and working.

    I have also installed MySQL and have it working.

    I cannot get the MySQL extension to work in PHP.

    Any suggestions?

  10. David.Wang says:

    Ken – you could just use ASP.Net and SQL Express 2005 – it’s all free and better development experience.


  11. Corey says:

    Thanks for the help David & Steve.

  12. jlrojas says:

    i cant install php please help….

    i install php on c:php

    i modify the .bat like these

    PUSHD %SYSTEMROOT%System32inetsrv

    APPCMD SET CONFIG -section:handlers -+[name=’PHP’,path=’*.php’,verb=’GET,HEAD,POST’,modules=’IsapiModule’,scriptProcessor=’%SYSTEMDRIVE%PHPphp.exe’,resourceType=’File’]

    APPCMD SET CONFIG -section:isapiCgiRestriction -+[path=’%SYSTEMDRIVE%PHPphp.exe’,allowed=’true’,groupId=’PHP’,description=’PHP5′]


    after install and confiure the php.ini in c:php

    i have the error..

    Server Error in ‘Default Web Site’ Application.


    HTTP Error 404.4 – Not Found

    Description: The resource you are looking for does not have a module or handler associated with it. It cannot be handled and served.

    Error Code: 0x00000000

    Notification: ExecuteRequestHandler

    Module: IIS Web Core

    Requested URL: http://localhost:80/fist/fistMain.php?site=example_site

    Physical Path: C:ms4wappsfisthtdocsfistMain.php

    Logon User: Anonymous

    Logon Method: Anonymous

    Handler: PHP


    The file extension for the requested URL does not have a module or handler configured to execute the request on the IIS server.


    If you determine that the file extension being denied is required by the Web server, add the appropriate handler for the file extension by following these steps:

    From the IISWeb Management tool, open a connection to the web site.

    Double click the Handlers Management feature.

    Click New Server Module Handler in the Tasks pane.

    Complete the Wizard pages to add the handler information, and then click Finish to add the handler to the list.

    Go back to the list of management features and double-click the ISAPI and CGI Restrictions Management feature.

    Click New Restriction in the Tasks pane.

    Complete information for the new extension, check Allow extension path to execute, and then click OK.

    Set up a new Failed Request Trace rule for this HTTP status code.

    Use the IIS Web Management tool to open a connection to the Web server where the problem is occurring.

    In the tree view, navigate to the Web site, and then click to select it.

    In the Tasks pane, click Failed Request Tracing.

    Check Enable Logging for this Site, specify a logging folder or use the default log folder, and then click OK

    Open the Failed Request Tracing Rules feature and click New Rule in the Tasks pane.

    Specify the content type to monitor and then click Next.

    Check the Status Codes checkbox, type 404.3 in the Edit box, and then click Next.

    In the Providers area, make sure that the WWW Server is checked and highlighted, and that in Provider Properties, the Verbosity level is set to Verbose.

    Click FinishRequest the page that generated the 404.3 error and then look at the tracing file that was created for the request. This file is located in the logging folder you specified in Step 4.

    More Information… This error means that the IIS server does not recognize the file extension of the requested resource. A module handler is not configured on the Web server for this extension. If the file extension being denied is required by the Web server, add the appropriate handler for the file extension.

    Microsoft Knowledge Base Articles:


    Server Version Information: Internet Information Services 7.0.

    please help me…..

    i use win vista beta 2

  13. David.Wang says:

    jlrojas – I suggest reading the custom error page and troubleshooting it yourself. I recommend using the ISAPI version of PHP on IIS.

    Also, I suggest following published directions and not make unknown modifications. Please understand that I am one person and simply cannot support getting everyone’s custom configuration of IIS7 to work with PHP.

    For example, ISAPI and CGI are different things. You configured the ISAPI Module to execute a CGI EXE binary, so that is incorrect. If you want to configure PHP CGI, there are additional PHP configuration steps to figure out – please consult PHP support on how PHP CGI works.

    Also, based on the error (404.4), it appears that you modified the available modules to process the request. That is non-default and needs to be stated.

    In general, if you stray from directions, then you should feel free to support your own modifications – it is beta software, after all.


  14. David Wang says:

    Hmm… it seems that ever since I made the blog entry about how to install PHP on IIS7, I seem to have…

  15. Psycho Dude says:

    I have just tried installing PHP along with IIS7 in the Beta 2 version of vista with your batch lines:


    PUSHD %SYSTEMROOT%System32inetsrv

    APPCMD SET CONFIG -section:handlers -+[name=’PHP’,path=’*.php’,verb=’GET,HEAD,POST’,modules=’IsapiModule’,scriptProcessor=’%SYSTEMDRIVE%InetpubPHPphp5isapi.dll’,resourceType=’File’]

    APPCMD SET CONFIG -section:isapiCgiRestriction -+[path=’%SYSTEMDRIVE%InetpubPHPphp5isapi.dll’,allowed=’true’,groupId=’PHP’,description=’PHP5′]


    I extracted the zip file to PHP in the Inetpub folder manually.

    All the info got nicely placed after running it as an admin and the IIS manager displays it as being there. When trying to acces a php file though I get a 404.4 error similar to jlrojas, just a different requested url and physical path.

    .htm files work nicely within the same directory so the directory itself is accesible well.

    Not that used to IIS since I usually run Apache, so I can hope you can help me out :).

  16. David.Wang says:

    Psycho Dude – Since IIS7 is all componentized – did you install all support to run the ISAPI Extension component, which is required to run PHP ISAPI?


  17. David Wang says:

    A couple of months ago, I wrote a quick and dirty entry on how to install PHP on IIS7. The main purpose…

  18. hyponiq says:

    Thanks very much for your advice.  It worked like a charm. 😉 @ David Wang’s article.

  19. Armando says:

    I have a problem:

    Service Unavailable


    HTTP Error 503. The service is unavailable.

    what happend?

  20. Robert Benn says:

    I have successfull installed php and Mysql on Vista and I can get phpinfo() to displat from the root directory. – I have set-up phpMyAdmin as a virtual directory on the localhost.

    A basic Html file in phpMyAdmin displays fine as the default page however my "test.php" which runs the phpinfo() gets a 404 error.

    ANy suggestions?  Thank you – Robert Benn

  21. Robert Benn says:

    Follow-up to Question:

    By putting phpmyadmin as a subdirectory in the wwwroot, the program phpinfo() and the phpmyadmin application was able to run

    thank you – Robert Benn

  22. Mark Maleson says:

    I followed your procedures to get php 5 installed under vista. Am getting:

    HTTP Error 500.0 – Internal Server Error

    Description: Handler "PHP" has a bad module "IsapiModule" in its module list

    Error Code: 0x8007000d

    Notification: ExecuteRequestHandler

    Module: IIS Web Core

    Requested URL: http://localhost:80/enchantment/t.php

    Physical Path: C:inetpubwwwrootenchantmentt.php

    Logon User: Anonymous

    Logon Method: Anonymous

    Handler: PHP

    Most likely causes:

       * A module is referenced in configuration, but the module has not been installed or the name of the module is misspelled.

       * IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.

       * IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.

       * IIS was not able to process configuration for the Web site or application.

       * The authenticated user does not have permission to use this DLL.

    What you can try:

       * Verify that the module is installed. The error description may contain additional information to help you determine which module is causing the error.

       * If the module is installed, verify that the module name is not misspelled in the configuration/system.webServer/handlers config section.

       * Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server’s machine account.

       * Check the event logs to see if any additional information was logged.

       * Verify the permissions for the DLL.

       * Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.

    I’ve tried to verify all of the above and can’t see the problem.



  23. Chris Fontanini says:

    I had PHP working on IIS7 under Server 2008 Beta 3 until I installed MySQL….now I get a 503 unavailable error….

    What happened?

  24. Boz says:

    Finally got it all to work but it was an incredibly frustrating experience, IIS7 is not going anywhere near my production server.

  25. David.Wang says:

    Boz – if you are already running IIS6 and have no real reason to upgrade, then I suggest you stay with IIS6.

    If you are running IIS5, then you should consider moving to IIS6 or IIS7, depending on needs.

    Personally, I prefer IIS7 over IIS6 because of its flexibility and better troubleshooting experience. However, I understand that for most end-users IIS7 will appear complex and frustrating because it is so flexible and easily misconfigured.  On the other hand, IIS7 is perfect for hosters or VARs to customize and resell to end-users…


  26. Upendra watwe says:

    Hello David ,

    This page has been very helpful, for me to configure PHP for IIS7, the detailed instructions were very useful now i guess i can dabble around in case i need to setup IIS7 for some other type of pages also. Helped to really understand the config file and how things fit together. The bit about the sequence of handlers was particularly useful.

    Thanks again

    Upendra watwe

  27. David.Wang says:

    Upendra – You’re welcome. I want to illustrate such critical details often missed in IIS documentation as well as the motivating factors behind them… so that people can learn and understand IIS7 instead of merely memorizing configuration steps.


  28. David.Wang says:

    Mark – your issue is because ISAPI support is not installed by default on IIS7, so PHP won’t run even with the proper configuration. You need to install ISAPI support within IIS7 and then you should move past that issue.


  29. Thomas says:

    I have ISAPI installed in IIS7 and I get the same basic errors as Mark, only with Perl.

  30. Mike Cham says:

    I ran into the same problem with the "Handler "PHP" has a bad module "IsapiModule" in its module list".  Something appears to be broken in the inheritance of Modules from the server to the Default Web Site cause the IsapiModule is listed at the server level, but doesn’t make it onto the list at the Default Web Site level.  If you delete the Default Web Site and then add it back, bingo the IsapiModule is now in the list at the web site level and like magic php starts working.  

    Big thanks to Ryan Dunn in this post

  31. Lesley says:

    I also got the 404 error and found it was caused by double quotes around directories in the php.ini file – once you get rid of these, all works.

    I then found http post request did not work – correct page displayed but blank.  I solved this by changing the verbs in the php handler mapping IIS7 from GET, HEAD, POST to the All verbs option -hope this helps someone.


  32. Phil says:

    I’m on Vista 64-bit.  Did a php-5.2.3-win32-installer.msi install and tried installing manually too, and didn’t work.  Followed all of the above steps including enabling 32-bit apps.  Didn’t work and still get the HTTP Error 404.3 – Not Found error.  Any ideas on what to do?  I am a ‘user’ and installed.  Didn’t want to disable user accounts and do just ‘admin’ all the time.  Could this have something to do with it?  Any other ideas?  I’m at a loss.  Thanks in advance.

  33. David.Wang says:

    Phil – 404.3 has nothing to do with user vs admin or anything else. It just means that you are trying to download a resource that does not have a MIME Type, so the IIS Static File Handler is denying access.

    If you are trying to request .php files, then the problem is that PHP is just not installed and setup properly. Specifically, the .php handler definition is missing.

    By default, IIS7 only supports static files and does not support running dynamic script like PHP (or ASP, ASP.Net for that matter). You need to ensure that you install IIS7 with the necessary support for ISAPI Extension and/or CGI (depending on which PHP version you want to use).

    Then, you need to make sure to configure a handler for .php with the necessary configuration and enable the ISAPI/CGI — that is what the batch script in this blog entry does.


  34. HoanLe says:

    Hi! I am also new to PHP. I do a lot of stuffs to find out how to run PHP on IIS7. This is the only way that works.

    I also used the PHP installer. I follow the steps above (I prefered to use ISAPI – not CGI and pointed installation path to %SYSTEMDRIVER%wwwrootPHP). The only differents were I only copied those lines:

    "PUSHD %SYSTEMROOT%System32inetsrv

    APPCMD SET CONFIG -section:handlers -+[name=’PHP’,path=’*.php’,verb=’GET,HEAD,POST’,modules=’IsapiModule’,scriptProcessor=’%SYSTEMDRIVE%InetpubPHPphp5isapi.dll’,resourceType=’File’]

    APPCMD SET CONFIG -section:isapiCgiRestriction -+[path=’%SYSTEMDRIVE%InetpubPHPphp5isapi.dll’,allowed=’true’,groupId=’PHP’,description=’PHP5′]


    and saved as a .bat file. Please do not forget to remove previous Handler Mappings to php5isapi if it existed.

  35. easy says:

    The 404.3 error only appears if the handler map is not responding, this error occurs when the MIME type does not work, please set it to application/x-httpd-php. This works, but sometimes this shows it as text, most businesses use PHP and ASP.NET on one server, but usually Apache, IIS7 is mainly static and is used to morphing ASP.NET to hypertext only. If you have this error, it may appear blank, the 404.3 request before would of been like this:

    Yes, it is PHP Advertiser.

    Server Error in Application "Default Web Site/Advertiser/Main"


    HTTP Error 404.3 – Not Found

    Description: The page you are requesting cannot be served because of the Multipurpose Internet Mail Extensions (MIME) map policy that is configured on the Web server. The page you requested has a file name extension that is not recognized, and is not allowed.

    Error Code: 0x80070032

    Notification: ExecuteRequestHandler

    Module: StaticFileModule

    Requested URL: http://localhost:80/Advertiser/Main/index.php

    Physical Path: C:inetpubwwwrootAdvertiserMainindex.php

    Logon User: Anonymous

    Logon Method: Anonymous

    Handler: StaticFile

    Most likely causes:

    It is possible that a handler mapping is missing. By default, the static file handler processes all content.

    The feature you are trying to use may not be installed.

    The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not create a MIME map for content that users should not download, such as .ASPX pages or .config files.)

    What you can try:

    In system.webServer/handlers:

    Ensure that the expected handler for the current page is mapped.

    Pay careful attention to preconditions (e.g. runtimeVersion, pipelineMode, bitness) and compare them to the settings for your application pool.

    Pay careful attention to typographical errors in the expected handler line.

    Please verify that the feature you are trying to use is installed.

    Verify that the MIME map is enabled or add the MIME map for the Web site using the command-line tool appcmd.exe.

    Open a command prompt and change directory to %windir%system32inetsrv.

    To set a MIME type, use the following syntax: appcmd set config /section:staticContent /+[fileExtension=’string’,mimeType=’string’]

    The variable fileExtension string is the file name extension and the variable mimeType string is the file type description.

    For example, to add a MIME map for a file which has the extension ".xyz", type the following at the command prompt, and then press Enter:

    appcmd set config /section:staticContent /+[fileExtension=’.xyz’,mimeType=’text/plain’]

    Warning: Ensure that this MIME mapping is needed for your Web server before adding it to the list. Configuration files such as .CONFIG or dynamic scripting pages such as .ASP or .ASPX, should not be downloaded directly and should always be processed through a handler. Other files such as database files or those used to store configuration, like .XML or .MDF, are sometimes used to store configuration information. Determine if clients can download these file types before enabling them.

    Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.

    More Information… This error occurs when the file extension of the requested URL is for a MIME type that is not configured on the server. You can add a MIME type for the file extension for files that are not dynamic scripting pages, database, or configuration files. Process those file types using a handler. You should not allows direct downloads of dynamic scripting pages, database or configuration files.


    Server Version Information: Internet Information Services 7.0

    You need the MIME type, use CGI instead.

  36. NoviceInstall says:

    Thanks for this post.

    I followed the instruction, but I still have the same problem as above. I even downloaded the PHPx64 Version from following the great and nice instruction of Blond R at

    But i’m still lost.

    Could you please advice ? I really don’t know what to do ;-(


    HTTP Error 404.3 – Not Found

    Description: The page you are requesting cannot be served because of the Multipurpose Internet Mail Extensions (MIME) map policy that is configured on the Web server. The page you requested has a file name extension that is not recognized, and is not allowed.

    Error Code: 0x80070032

    Notification: ExecuteRequestHandler

    Module: StaticFileModule

    Requested URL: http://localhost:80/test.php

    Physical Path: C:inetpubwwwroottest.php


  37. NoviceInstall says:

    It’s me again. By the way, I don’t understand why should I create an C:inetpubPHP instead of C:PHP ?

  38. Rick says:

    After running the script, I get the HTTP Error 500.0 error – Handler "PHP" has a bad module "IsapiModule" in its module list.  Could someone please give me detailed instructions for fixing this?

  39. Rick says:

    I figured out my problem with the 500.0 error.  Apparently IIS7 defaults to none of the ISAPI or CGI scripting features.  You have to turn on these features.  Go to Control Panel->Programs and Features.  Click on "Turn Windows features on or off".  Under Internet Information Services->World Wide Web Services->Application Development Features, check the needed boxes.  I just checked them all.  This fixed my problem.

  40. Shane says:

    I created a batch file that did the following (using my own directories)

    PUSHD C:WindowsSystem32inetsrv

    APPCMD SET CONFIG -section:handlers –[name=’StaticFile’,path=’*’,verb=’*’]

    APPCMD SET CONFIG -section:handlers -+


    APPCMD SET CONFIG -section:handlers -+



    APPCMD SET CONFIG -section:isapiCgiRestriction -+[path=’C:wwwPHPphp5isapi.dll’,allowed=’true’,groupId=’PHP’,description=’PHP5′]


    I get the following error after the last bit of code runs (the isapiCgiRestriction):

    ERROR ( message:New add object missing required attributes.  Cannot add duplicate collection entry.)

    What gives?

  41. Shane says:

    I guess I should also note I’m still getting the handler exception error.   404.3

  42. Wild Thing says:


    I wanted to install PHP on my IIS 7, because I was already using IIS7 for ASP.

    But looking on the ‘net for the 404.3 error resolution, I realize that tons of others are facing the same problem, and it’s a pain in the a$$ to fix.

    IIS7 sucks. I’ll just configure Apache instead.

  43. kmiles says:

    I’ve configured everything as above, but when I go to a test.php page, it just says "loading" and never does anything. Any ideas?

  44. The solution to the 404.3 issue can be found at:

    It contains information not addressed by the posts above – The 404.3 has to do with the application pool setting to "Enable 32-bit applications" (I’m running 64-bit)

    This solved the 404.3 issue in my case.

    Hope it helps – almost all googling points to this page and it did not really help!

  45. Bosslb says:

    Hello, just forget all about iis7, I had a headache for many days trying to run PHP on vista, then I got the real solution, which is, uninstall IIS, and go download  wamp5 from and install it, and Finito, php will run as smooth as never before!

    have fun all 🙂

  46. staylor says:

    I recieved the error ‘HTTP Error 500.0 – Internal Server Error’ when trying to install PHP w/ the guidance of this article. OS is Windows Server 2008 Beta 3

    Enabling 32-bit applications in Advanced Settings on the application pool resolved this issue.

  47. David.Wang says:

    Everyone – note the date when this blog entry was written — in early 2006, before IIS7 was released.

    Do I think it is dated? Of course. Do I plan to do anything about it? Not really. Back in 2006, I needed to fill the gap between IIS7 release and other people taking up the mantle, and that’s what this blog entry served.

    IIS7 is now released, so I really want PHP users to go elsewhere for their PHP support.

    However, having surveyed some of those places, including, I have to say that PHP users who have made posts don’t know a lot about IIS, don’t seem to know how to find information about IIS, and there are lots of silly folklore out there. I don’t want to post to dispel some of those rumors because I’ll probably just be tarred and feathered for being a Windows and IIS advocate on a PHP forum. 🙂 Hopefully, some of you can do this for me…

    The REASON why the 404.3 results from installing PHP is this: If IIS fails to find a handler for a request, it will eventually be handled by the StaticFileHandler since it’s usually the last configured handler, and becausue it does not have a MIME Type entry for .php, you will get a 404.3 if a PHP request gets handled by it.

    Thus, the real question is why the PHP handler this script added was NOT recognized prior to the StaticFileHandler, and why changing bitness to 32bit fixes it. Well, if the PHP handler had a bitness32 preCondition, which is supposed to match the bitness of the PHP ISAPI DLL, and you run it on a 64bit IIS7 machine, the handler will not be recognized by IIS *UNLESS* the Application Pool is running in 32bit mode.

    Since you are installing a 32bit DLL on 64bit OS, it follows that you need to configure IIS7 to load it as 32bit.

    Apache skirts this bitness issue because its extensibility is at the process level, and since 32bit and 64bit processes can invoke each other, there is no requirement to match bitness. However, this approach is inefficient on Windows. IIS uses in-process extensibility with ISAPI DLLs and IIS Modules, so bitness matching is a requirement, but it also brings performance benefits.

    As usual, with power comes responsibility.

    In the end, this is just another instance of mismatching bitness. On IIS6, this misconfiguration would have resulted in a 503 Service Unavailable, a mess which I described in other blog entries. On IIS7, depending on preCondition values, one can get a variety of results, but at least it is possible to avoid bitness crashes on IIS7.


  48. Kris says:

    Your script worked flawlessly, Thank You!

  49. WhiteTimer says:

    I have just reinstalled IIS7 with CGI & PHP 5.2.5.  I have followed the tutorial "using-fastcgi-to-host-php-applications-on-iis7" .  Then i did C:php>php -info which ran, but as i scroll through the output i notice that there is no reference to Document Root.


    json support => enabled

    json version => 1.2.1


    libXML support => active

    libXML Version => 2.6.26

    libXML streams => enabled


    ODBC Support => enabled

    Active Persistent Links => 0

    Active Links => 0

    ODBC library => Win32

    Directive => Local Value => Master Value

    odbc.allow_persistent => On => On

    odbc.check_persistent => On => On

    odbc.default_db => no value => no value

    odbc.default_pw => no value => no value

    odbc.default_user => no value => no value

    odbc.defaultbinmode => return as is => return as is

    odbc.defaultlrl => return up to 4096 bytes => return up to 4096 bytes

    odbc.max_links => Unlimited => Unlimited

    odbc.max_persistent => Unlimited => Unlimited


    PCRE (Perl Compatible Regular BLOCKED EXPRESSION Support => enabled

    PCRE Library Version => 7.3 2007-08-28

    Directive => Local Value => Master Value

    pcre.backtrack_limit => 100000 => 100000

    pcre.recursion_limit => 100000 => 100000


    Reflection => enabled

    Version => $Id: php_reflection.c,v 2007/10/28 13:47:14 iliaa Exp



    Session Support => enabled

    Registered save handlers => files user

    Registered serializer handlers => php php_binary wddx

    Directive => Local Value => Master Value

    session.auto_start => Off => Off

    session.bug_compat_42 => On => On

    session.bug_compat_warn => On => On

    session.cache_expire => 180 => 180

    session.cache_limiter => nocache => nocache

    session.cookie_domain => no value => no value

    session.cookie_httponly => Off => Off

    session.cookie_lifetime => 0 => 0

    session.cookie_path => / => /

    session.cookie_secure => Off => Off

    session.entropy_file => no value => no value

    session.entropy_length => 0 => 0

    session.gc_divisor => 100 => 100

    session.gc_maxlifetime => 1440 => 1440

    session.gc_probability => 1 => 1

    session.hash_bits_per_character => 4 => 4

    session.hash_function => 0 => 0 => PHPSESSID => PHPSESSID

    session.referer_check => no value => no value

    session.save_handler => files => files

    session.save_path => no value => no value

    session.serialize_handler => php => php

    session.use_cookies => On => On

    session.use_only_cookies => Off => Off

    session.use_trans_sid => 0 => 0

    PHP Variables

    Variable => Value


    _SERVER["APPDATA"] => C:UsersJulian C CorbettAppDataRoaming

    _SERVER["CLASSPATH"] => .;

    _SERVER["CommonProgramFiles"] => C:Program FilesCommon Files


    _SERVER["ComSpec"] => C:Windowssystem32cmd.exe



    _SERVER["HOMEPATH"] => UsersJulian C Corbett

    _SERVER["JAVA_HOME"] => C:Javajdk1.6.0

    _SERVER["LOCALAPPDATA"] => C:UsersJulian C CorbettAppDataLocal



    _SERVER["OS"] => Windows_NT

    _SERVER["Path"] => C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:Pr

    ogram FilesATI TechnologiesATI.ACECore-Static;C:php;C:Program FilesQuickTi




    _SERVER["PROCESSOR_IDENTIFIER"] => x86 Family 15 Model 4 Stepping 1, GenuineInte




    _SERVER["ProgramData"] => C:ProgramData

    _SERVER["ProgramFiles"] => C:Program Files

    _SERVER["PROMPT"] => $P$G

    _SERVER["PUBLIC"] => C:UsersPublic

    _SERVER["QTJAVA"] =>

    _SERVER["SESSIONNAME"] => Console

    _SERVER["SystemDrive"] => C:

    _SERVER["SystemRoot"] => C:Windows

    _SERVER["TEMP"] => C:UsersJULIAN~1AppDataLocalTemp

    _SERVER["TMP"] => C:UsersJULIAN~1AppDataLocalTemp


    _SERVER["USERNAME"] => Julian C Corbett

    _SERVER["USERPROFILE"] => C:UsersJulian C Corbett

    _SERVER["windir"] => C:Windows

    _SERVER["PHP_SELF"] =>





    _SERVER["REQUEST_TIME"] => 1208469854

    _SERVER["argv"] => Array



    _SERVER["argc"] => 0

    _ENV["ALLUSERSPROFILE"] => C:ProgramData

    _ENV["APPDATA"] => C:UsersJulian C CorbettAppDataRoaming

    _ENV["CLASSPATH"] => .;

    _ENV["CommonProgramFiles"] => C:Program FilesCommon Files


    _ENV["ComSpec"] => C:Windowssystem32cmd.exe


    _ENV["HOMEDRIVE"] => C:

    _ENV["HOMEPATH"] => UsersJulian C Corbett

    _ENV["JAVA_HOME"] => C:Javajdk1.6.0

    _ENV["LOCALAPPDATA"] => C:UsersJulian C CorbettAppDataLocal



    _ENV["OS"] => Windows_NT

    _ENV["Path"] => C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:Progr

    am FilesATI TechnologiesATI.ACECore-Static;C:php;C:Program FilesQuickTime




    _ENV["PROCESSOR_IDENTIFIER"] => x86 Family 15 Model 4 Stepping 1, GenuineIntel



    _ENV["ProgramData"] => C:ProgramData

    _ENV["ProgramFiles"] => C:Program Files

    _ENV["PROMPT"] => $P$G

    _ENV["PUBLIC"] => C:UsersPublic

    _ENV["QTJAVA"] =>

    _ENV["SESSIONNAME"] => Console

    _ENV["SystemDrive"] => C:

    _ENV["SystemRoot"] => C:Windows

    _ENV["TEMP"] => C:UsersJULIAN~1AppDataLocalTemp

    _ENV["TMP"] => C:UsersJULIAN~1AppDataLocalTemp


    _ENV["USERNAME"] => Julian C Corbett

    _ENV["USERPROFILE"] => C:UsersJulian C Corbett

    _ENV["windir"] => C:Windows

    PHP License

    This program is free software; you can redistribute it and/or modify

    it under the terms of the PHP License as published by the PHP Group

    and included in the distribution in the file:  LICENSE

    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of


    If you did not receive a copy of the PHP license, or have any

    questions about PHP licensing, please contact


    Why is that ? And how do i rectify that ?

    Many thanks


  50. David.Wang says:

    WhiteTimer – What you see is by-design.

    Those values depend on having a URL-to-PhysicalPath mapping, which is present when the web server launches PHP.EXE.

    You did not set those corresponding values when you launched PHP.EXE from the command shell, so those values are missing as expected.


  51. Sonny0 says:

    have followed, even use the appcmd, lots of failures and will not see php at all. i am trying to get cerbreus and sugarcrm working

  52. David.Wang says:

    Sonny0 – Unfortunately, I cannot troubleshoot your failed PHP installations, nor will my script "fix" whatever misconfiguration to make PHP work on IIS7.

    If you can ask a specific question, I can try to make forward progress.

    Otherwise, I can only suggest to format and reinstall Vista. Install IIS7 Clean with CGI and ISAPI support (depends on what you want to use). Follow my instructions. It works – many people have had success.

    For troubleshooting assistance, you need to contact the PHP support groups.


  53. Craig says:

    I’ve just installed ver 5.2.5 (x64) on my Vista x64 set-up with IIS7. PHP appears to be working fine. php.ini found, etc, and phpinfo() plus other basic commands like echo() work just fine, and pages are happily generated.

    However when I try to access my old website(s), I run into IIS7 error pages. There are several scenarios:

    [*] Virtual directory – HTTP Error 500.19 – Internal Server Error. It goes on about "Cannot read configuration file due to insufficient permissions", referencing web.config in the site root (which is strange, because this is all PHP and not ASP!).

    [*] wwwroot – a more generic HTTP Error 500 which is totally unhelpful. This error appears for the same file as above, if it is copied from the virtual dir to the wwwroot. In other words the error differs depending on whether the file is in the wwwroot or the virtual dir. File permissions with the files that do work are identical. I even tried creating a new file and copying the code over, so the file was new with inherited permissions. But it made no difference.

    [*] I mucked around with file permissions for a while, and changed "physical path credentials" to my specific user account (rather than pass through authentication). This changed the IIS error to a simple text output: "Input file required". I assume that’s a wild goose chase.

    I have done a totally standard install, and as above, PHP x64 does appear to be working okay, at least at a basic level. Does anyone have any idea why on earth I am getting these IIS7 errors for my old files?

  54. David.Wang says:

    Craig – IIS7 stores its configuration in distributed .config files, so web.config files once used by ASP.Net will also apply for IIS7 configuration, even if you are serving PHP.

    Overall, it sounds like you have NTFS ACL problems on your old websites, such that it is not accessible to IIS7

    – hence the problem with reading .config files due to insufficient permission

    – directory NTFS ACLs are just as important as the ACLs on each file, which could be the difference in behavior between virtual directory and wwwroot

    – when you changed the user account IIS uses to execute requests, it sounds like IIS7 was finally able to read configuration and files and attempt to execute the PHP handler, but the handler failed, possibly misconfigured.

    I would recommend installing the "Failed Request Tracing" feature of IIS7, enabling it for this website and create a rule for capturing failing request/response, and see what it says.

    The trace is the most concise way to troubleshoot IIS7 – far better than any log file and certainly better than the custom error responses which you call "generic" — because error response NEED to be generic for security reasons. Since traces can only be available on the server itself, it contains all necesarry information. Its only problem is that it is detailed and concise and therefore requires more knowledge and effort to wield effective.


  55. anon says:

    hi, i am using IIS7 to run PHP – the issue is that when i use certain authentications there seems to be some file permission errors. For example when i use Windows authentication i am not able to write into a file. For this i have no clue as to which user group i need to give the file permission. On the other hand while using the basic authentication  i do not get this message. Initially i had the issue with the anonymous authentication as well bit i rectified this by given write access to all users of my machine (though i know this is not the right way). What am i missing for Windows authentication. The same code used to work without any issues in IIS6 with the same set of permissions. This is the error i get : Warning: fopen(file.txt) [function.fopen]: failed to open stream: Permission denied in ]. Any help would be highly appreciated.


  56. David.Wang says:

    anon – You can use FileMon from to monitor file access (and access denies) to determine file and username.

    Failure on Windows Authentication and success on Basic Authentication suggest double-hop issues (is the failing file access on a remote filesystem?) If so, that is a user configuration issue.


  57. Anon says:

    The php script is trying to access a file in the local machine. I tried running processmon and found that the user id use was NT AUTHORITY/NETWORK SERVICE. Tried giving write access to NETWORK SERVICE and still got the same error.

    I then tried creating a new application pool, with the user id as an admin of this machine. Still the same error, but now the user id shown in processmon is the admin id provided in the applcation pool.

  58. lvs says:

    Thanks for the post.. it helped me… and its working smoothly.. 😉

  59. Anon says:

    i moved all the files to the D drive and it worked fine.

  60. Joe Vivona says:

    For anyone who is getting info.php to work when it is in the wwwroot directory (and subdirectories), but not when it is somewhere else in your path.  Check the value of   open_basedir in your php.ini file.   this setting restricts where php files can reside and be run from.   so if you have this set to be c:inetpubwwwroot and you have a php file in c:inetpubblog, IT WILL NOT RUN and you will get a 404 error.   I commented this value out as my machine is dedicated for web hosting only.   Or using the above example you could set it to be   c:inetpub

  61. Billy says:

    i have php up and running via fast cgi and its working ok in the main folder. but if i call any subfolders i get a 500 error, even if i try to call the .php file directly.

    does anyone know why the main folder would work but sub folders will not?

    ie.    works

    but    does not work


  62. David.Wang says:

    Billy – you should turn on Failed Request Tracing in IIS7 to troubleshoot your misconfiguration.


  63. G says:

    Thanks for the post. I was trying to install php outside of inetpub and was having trouble.

    I installed php inside Inetpub then went into IIS Config Manager and clicked on "Add Script Map…" then set Request Path to "*.php", Executable path to the php install path (c:inetpubphp) and filled in the name field…and bingo!

    Oh, I added the user account (IIS_IUSRS) to the php dir [permissions]

    …I love Apache but didn’t feel like installing on my laptop along with IIS 🙂

  64. Robin says:

    Hi guys.

    I’m came here because I got stuck. I have IIS7 running for C# and ASP2.NET projects. Opsys is Vistas Ultimate (SP1).

    I also want to support PHP and PostgreSQL for my current contract. I have PHP running phpinfo() and PostgreSQL running pgadmin. The application code is present, but the include file ( has a require for DB.php which I’m told is PEAR. Well I now have that running console via pear.bat.

    The include fails to find DB.php – no file of that name on the system.

    Any clues or pointers would be most welcome, please !!

    I just can’t seem to get IIS7 to tie it all together properly.

  65. Robin says:

    Update:  additional command to set-up pear PDO:   pear install db

    This solves this issue and let’s us find tghe next one . . . connection string differences between ‘Nix and Win

  66. Roy says:

    Thanks Garry Trinder for your useful post.

    I also refer very helpful and useful article about How to host PHP on IIS

    Please visit this helpful article article…/How%20to%20host%20PHP%20on%20IIS…/configure-a-php-website-on-iis

Comments are closed.

Skip to main content