次の方法で共有


HOWTO: Install and run PHP on IIS7

Question:

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

Answer:

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.

Instructions

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 https://www.php.net/downloads.php )
  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:

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

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. :-)

MKDIR %SYSTEMDRIVE%\Inetpub\PHP
ECHO Extract PHP files from ZIP archive into %SYSTEMDRIVE%\Inetpub\PHP
COPY /Y %SYSTEMDRIVE%\Inetpub\PHP\PHP.INI-Recommended %SYSTEMDRIVE%\Inetpub\PHP\PHP.INI
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']
POPD

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 ;-) ).

Conclusion

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.

//David

Comments

  • Anonymous
    April 04, 2006
    Oh, thanks a lot!

  • Anonymous
    June 02, 2006
    The comment has been removed

  • Anonymous
    June 05, 2006
    The comment has been removed

  • Anonymous
    June 05, 2006
    The comment has been removed

  • Anonymous
    June 13, 2006
    The comment has been removed

  • Anonymous
    June 14, 2006
    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.

    //David

  • Anonymous
    June 14, 2006
    The comment has been removed

  • Anonymous
    June 14, 2006
    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.

    //David

  • Anonymous
    June 15, 2006
    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?

  • Anonymous
    June 15, 2006
    Ken - you could just use ASP.Net and SQL Express 2005 - it's all free and better development experience.

    //David

  • Anonymous
    June 15, 2006
    Thanks for the help David & Steve.

  • Anonymous
    June 15, 2006
    The comment has been removed

  • Anonymous
    June 15, 2006
    The comment has been removed

  • Anonymous
    June 15, 2006
    Hmm... it seems that ever since I made the blog entry about how to install PHP on IIS7, I seem to have...

  • Anonymous
    June 18, 2006
    The comment has been removed

  • Anonymous
    June 19, 2006
    The comment has been removed

  • Anonymous
    June 21, 2006
    A couple of months ago, I wrote a quick and dirty entry on how to install PHP on IIS7. The main purpose...

  • Anonymous
    June 24, 2006
    The comment has been removed

  • Anonymous
    September 05, 2006
    I have a problem:

    Service Unavailable

    --------------------------------------------------------------------------------

    HTTP Error 503. The service is unavailable.

    what happend?

  • Anonymous
    May 25, 2007
    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

  • Anonymous
    May 26, 2007
    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

  • Anonymous
    May 30, 2007
    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. Thanks, Mark

  • Anonymous
    June 01, 2007
    I had PHP working on IIS7 under Server 2008 Beta 3 until I installed MySQL....now I get a 503 unavailable error.... What happened?

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

  • Anonymous
    June 23, 2007
    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... //David

  • Anonymous
    June 27, 2007
    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 upendra.watwe@gmail.com

  • Anonymous
    July 01, 2007
    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. //David

  • Anonymous
    July 01, 2007
    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. //David

  • Anonymous
    July 11, 2007
    I have ISAPI installed in IIS7 and I get the same basic errors as Mark, only with Perl.

  • Anonymous
    July 11, 2007
    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 http://dunnry.com/blog/IIS7And4043Error.aspx

  • Anonymous
    July 15, 2007
    The comment has been removed

  • Anonymous
    July 15, 2007
    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.

  • Anonymous
    July 20, 2007
    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. //David

  • Anonymous
    July 24, 2007
    The comment has been removed

  • Anonymous
    August 02, 2007
    The comment has been removed

  • Anonymous
    August 21, 2007
    Thanks for this post. I followed the instruction, but I still have the same problem as above. I even downloaded the PHPx64 Version from http://www.fusionxlan.com/PHPx64.php following the great and nice instruction of Blond R at http://blondr.blogspot.com/2006/11/set-up-iis-7-w-mysql-and-php-5.html 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

  • Anonymous
    August 21, 2007
    It's me again. By the way, I don't understand why should I create an C:inetpubPHP instead of C:PHP ?

  • Anonymous
    August 23, 2007
    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?

  • Anonymous
    August 24, 2007
    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.

  • Anonymous
    September 04, 2007
    The comment has been removed

  • Anonymous
    September 04, 2007
    I guess I should also note I'm still getting the handler exception error.   404.3

  • Anonymous
    September 18, 2007
    The comment has been removed

  • Anonymous
    September 24, 2007
    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?

  • Anonymous
    September 28, 2007
    The solution to the 404.3 issue can be found at: http://blog.ilikeu2.nl/2007/01/12/iis7-http-error-4043-not-found-for-php-cfm-etc/ 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!

  • Anonymous
    October 11, 2007
    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 http://www.wampserver.com/ and install it, and Finito, php will run as smooth as never before! have fun all :-)

  • Anonymous
    October 15, 2007
    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.

  • Anonymous
    November 17, 2007
    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 php.net, 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. //David

  • Anonymous
    November 28, 2007
    Here is a very simple procedure worked for me - http://hajuria.blogspot.com/2007/11/installing-iis7-php5-25-on-windows.html

  • Anonymous
    January 21, 2008
    Your script worked flawlessly, Thank You!

  • Anonymous
    April 17, 2008
    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 json support => enabled json version => 1.2.1 libxml libXML support => active libXML Version => 2.6.26 libXML streams => enabled odbc 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 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 Reflection => enabled Version => $Id: php_reflection.c,v 1.164.2.33.2.47 2007/10/28 13:47:14 iliaa Exp $ session 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 session.name => 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["ALLUSERSPROFILE"] => C:ProgramData _SERVER["APPDATA"] => C:UsersJulian C CorbettAppDataRoaming _SERVER["CLASSPATH"] => .;C:Javajre1.6.0libextQTJava.zip _SERVER["CommonProgramFiles"] => C:Program FilesCommon Files _SERVER["COMPUTERNAME"] => CORBETT-DT _SERVER["ComSpec"] => C:Windowssystem32cmd.exe _SERVER["FP_NO_HOST_CHECK"] => NO _SERVER["HOMEDRIVE"] => C: _SERVER["HOMEPATH"] => UsersJulian C Corbett _SERVER["JAVA_HOME"] => C:Javajdk1.6.0 _SERVER["LOCALAPPDATA"] => C:UsersJulian C CorbettAppDataLocal _SERVER["LOGONSERVER"] => \CORBETT-DT _SERVER["NUMBER_OF_PROCESSORS"] => 2 _SERVER["OS"] => Windows_NT _SERVER["Path"] => C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:Pr ogram FilesATI TechnologiesATI.ACECore-Static;C:php;C:Program FilesQuickTi meQTSystem _SERVER["PATHEXT"] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC _SERVER["PROCESSOR_ARCHITECTURE"] => x86 _SERVER["PROCESSOR_IDENTIFIER"] => x86 Family 15 Model 4 Stepping 1, GenuineInte l _SERVER["PROCESSOR_LEVEL"] => 15 _SERVER["PROCESSOR_REVISION"] => 0401 _SERVER["ProgramData"] => C:ProgramData _SERVER["ProgramFiles"] => C:Program Files _SERVER["PROMPT"] => $P$G _SERVER["PUBLIC"] => C:UsersPublic _SERVER["QTJAVA"] => C:Javajre1.6.0libextQTJava.zip _SERVER["SESSIONNAME"] => Console _SERVER["SystemDrive"] => C: _SERVER["SystemRoot"] => C:Windows _SERVER["TEMP"] => C:UsersJULIAN~1AppDataLocalTemp _SERVER["TMP"] => C:UsersJULIAN~1AppDataLocalTemp _SERVER["USERDOMAIN"] => CORBETT-DT _SERVER["USERNAME"] => Julian C Corbett _SERVER["USERPROFILE"] => C:UsersJulian C Corbett _SERVER["windir"] => C:Windows _SERVER["PHP_SELF"] => _SERVER["SCRIPT_NAME"] => _SERVER["SCRIPT_FILENAME"] => _SERVER["PATH_TRANSLATED"] => _SERVER["DOCUMENT_ROOT"] => _SERVER["REQUEST_TIME"] => 1208469854 _SERVER["argv"] => Array ( ) _SERVER["argc"] => 0 _ENV["ALLUSERSPROFILE"] => C:ProgramData _ENV["APPDATA"] => C:UsersJulian C CorbettAppDataRoaming _ENV["CLASSPATH"] => .;C:Javajre1.6.0libextQTJava.zip _ENV["CommonProgramFiles"] => C:Program FilesCommon Files _ENV["COMPUTERNAME"] => CORBETT-DT _ENV["ComSpec"] => C:Windowssystem32cmd.exe _ENV["FP_NO_HOST_CHECK"] => NO _ENV["HOMEDRIVE"] => C: _ENV["HOMEPATH"] => UsersJulian C Corbett _ENV["JAVA_HOME"] => C:Javajdk1.6.0 _ENV["LOCALAPPDATA"] => C:UsersJulian C CorbettAppDataLocal _ENV["LOGONSERVER"] => \CORBETT-DT _ENV["NUMBER_OF_PROCESSORS"] => 2 _ENV["OS"] => Windows_NT _ENV["Path"] => C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:Progr am FilesATI TechnologiesATI.ACECore-Static;C:php;C:Program FilesQuickTime QTSystem _ENV["PATHEXT"] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC _ENV["PROCESSOR_ARCHITECTURE"] => x86 _ENV["PROCESSOR_IDENTIFIER"] => x86 Family 15 Model 4 Stepping 1, GenuineIntel _ENV["PROCESSOR_LEVEL"] => 15 _ENV["PROCESSOR_REVISION"] => 0401 _ENV["ProgramData"] => C:ProgramData _ENV["ProgramFiles"] => C:Program Files _ENV["PROMPT"] => $P$G _ENV["PUBLIC"] => C:UsersPublic _ENV["QTJAVA"] => C:Javajre1.6.0libextQTJava.zip _ENV["SESSIONNAME"] => Console _ENV["SystemDrive"] => C: _ENV["SystemRoot"] => C:Windows _ENV["TEMP"] => C:UsersJULIAN~1AppDataLocalTemp _ENV["TMP"] => C:UsersJULIAN~1AppDataLocalTemp _ENV["USERDOMAIN"] => CORBETT-DT _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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact license@php.net. c:php> Why is that ? And how do i rectify that ? Many thanks WhiteTimer

  • Anonymous
    April 18, 2008
    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. //David

  • Anonymous
    June 02, 2008
    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

  • Anonymous
    June 03, 2008
    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. //David

  • Anonymous
    June 26, 2008
    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?

  • Anonymous
    June 27, 2008
    The comment has been removed

  • Anonymous
    August 11, 2008
    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. TIA

  • Anonymous
    August 11, 2008
    anon - You can use FileMon from Sysinternals.com 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. //David

  • Anonymous
    August 11, 2008
    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.

  • Anonymous
    August 12, 2008
    Thanks for the post.. it helped me... and its working smoothly.. ;)

  • Anonymous
    August 18, 2008
    i moved all the files to the D drive and it worked fine.

  • Anonymous
    December 22, 2008
    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

  • Anonymous
    January 07, 2009
    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. www.mysite.com    works but www.mysite.com/admin    does not work thanks

  • Anonymous
    January 09, 2009
    Billy - you should turn on Failed Request Tracing in IIS7 to troubleshoot your misconfiguration. //David

  • Anonymous
    January 21, 2009
    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 :)

  • Anonymous
    April 08, 2009
    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 (HeaderFunctions.inc) 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.

  • Anonymous
    April 08, 2009
    The comment has been removed

  • Anonymous
    October 13, 2015
    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 www.mindstick.com/.../How%20to%20host%20PHP%20on%20IIS www.iis.net/.../configure-a-php-website-on-iis