Microsoft IIS 5.1 and IIS 6.0
This section contains instructions for manually setting up Internet Information Services (IIS) 5.1 and IIS 6.0 to work with PHP on Microsoft Windows XP and Windows Server 2003. For instructions on setting up IIS 7.0 and later versions on Windows Vista, Windows Server 2008, Windows 7 and Windows Server 2008 R2 refer to Microsoft IIS 7.0 and later.
Configuring IIS to process PHP requests
Download and install PHP in accordance to the instructions described in manual installation steps
Замечание:
Non-thread-safe build of PHP is recommended when using IIS. The non-thread-safe builds are available at » PHP for Windows: Binaries and Sources Releases.
Configure the CGI- and FastCGI-specific settings in php.ini file as shown below:
Пример #1 CGI and FastCGI settings in php.ini
fastcgi.impersonate = 1 fastcgi.logging = 0 cgi.fix_pathinfo=1 cgi.force_redirect = 0
Download and install the » Microsoft FastCGI Extension for IIS 5.1 and 6.0. The extension is available for 32-bit and 64-bit platforms - select the right download package for your platform.
Configure the FastCGI extension to handle PHP-specific requests by running the command shown below. Replace the value of the "-path" parameter with the absolute file path to the php-cgi.exe file.
Пример #2 Configuring FastCGI extension to handle PHP requests
cscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:"PHP" ^ -extension:php -path:"C:\PHP\php-cgi.exe"
This command will create an IIS script mapping for *.php file extension, which will result in all URLs that end with .php being handled by FastCGI extension. Also, it will configure FastCGI extension to use the executable php-cgi.exe to process the PHP requests.
Замечание:
At this point the required installation and configuration steps are completed. The remaining instructions below are optional but highly recommended for achieving optimal functionality and performance of PHP on IIS.
Impersonation and file system access
It is recommended to enable FastCGI impersonation in PHP when using IIS. This is controlled by the fastcgi.impersonate directive in php.ini file. When impersonation is enabled, PHP will perform all the file system operations on behalf of the user account that has been determined by IIS authentication. This ensures that even if the same PHP process is shared across different IIS web sites, the PHP scripts in those web sites will not be able to access each others' files as long as different user accounts are used for IIS authentication on each web site.
For example IIS 5.1 and IIS 6.0, in its default configuration, has anonymous authentication enabled with built-in user account IUSR_<MACHINE_NAME> used as a default identity. This means that in order for IIS to execute PHP scripts, it is necessary to grant IUSR_<MACHINE_NAME> account read permission on those scripts. If PHP applications need to perform write operations on certain files or write files into some folders then IUSR_<MACHINE_NAME> account should have write permission to those.
To determine which user account is used by IIS anonymous authentication, follow these steps:
-
In the Windows Start Menu choose "Run:", type "inetmgr" and click "Ok";
-
Expand the list of web sites under the "Web Sites" node in the tree view, right-click on a web site that is being used and select "Properties";
-
Click the "Directory Security" tab;
-
Take note of a "User name:" field in the "Authentication Methods" dialog
To modify the permissions settings on files and folders, use the Windows Explorer user interface or icacls command.
Пример #3 Configuring file access permissions
icacls C:\inetpub\wwwroot\upload /grant IUSR:(OI)(CI)(M)
Set index.php as a default document in IIS
The IIS default documents are used for HTTP requests that do not specify a document name. With PHP applications, index.php usually acts as a default document. To add index.php to the list of IIS default documents, follow these steps:
-
In the Windows Start Menu choose "Run:", type "inetmgr" and click "Ok";
-
Right-click on the "Web Sites" node in the tree view and select "Properties";
-
Click the "Documents" tab;
-
Click the "Add..." button and enter "index.php" for the "Default content page:".
FastCGI and PHP Recycling configuration
Configure IIS FastCGI extension settings for recycling of PHP processes by using the commands shown below. The FastCGI setting instanceMaxRequests controls how many requests will be processed by a single php-cgi.exe process before FastCGI extension shuts it down. The PHP environment variable PHP_FCGI_MAX_REQUESTS controls how many requests a single php-cgi.exe process will handle before it recycles itself. Make sure that the value specified for FastCGI InstanceMaxRequests setting is less than or equal to the value specified for PHP_FCGI_MAX_REQUESTS.
Пример #4 Configuring FastCGI and PHP recycling
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^ -InstanceMaxRequests:10000 cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^ -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000
Configuring FastCGI timeout settings
Increase the timeout settings for FastCGI extension if there are applications that have long running PHP scripts. The two settings that control timeouts are ActivityTimeout and RequestTimeout. Refer to » Configuring FastCGI Extension for IIS 6.0 for more information about those settings.
Пример #5 Configuring FastCGI timeout settings
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^ -ActivityTimeout:90 cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^ -RequestTimeout:90
Changing the Location of php.ini file
PHP searches for php.ini file in several locations and it is possible to change the default locations of php.ini file by using PHPRC environment variable. To instruct PHP to load the configuration file from a custom location run the command shown below. The absolute path to the directory with php.ini file should be specified as a value of PHPRC environment variable.
Пример #6 Changing the location of php.ini file
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" ^ -EnvironmentVars:PHPRC:"C:\Some\Directory\"
Коментарии
i`ve the same trouble after the install php 5.2.14-nts on IIS6 (Win2003Server)- try to open-dialog when php-file is opening...
I`ve to manual add .php in "Application configuration" ... \system32\inetsrv\fcgiext.dll (even this option selected in installation - "Script executable")
this solved the problem :)
I am using Win 2003 Server, IIS 6, PHP 5.
If you see "You are not authorized to view this page" error when running your PHP page.
Try one more thing:
1. Right-click {C:\php} (or your PHP installation root) and select {Properties}
2. Select {Security} tab and click {Add} button
3. Enter {ComputerName/IUSR_ComputerName} as object name and press {OK}
4. Select {Read & Execute} as permissions
5. Click {Advanced} button and select {Allow inheritable permissions from the parent...} checkbox
6. Press {OK}
A note for your reference ... I was getting error 404 "file not found when trying to browse .php" files in \inetpub\wwwroot although .html files worked fine... messed around for hours until I tried this on advice of a friend.
FYI ...
Operating system Windows Server 2003 SP2 x64
IIS v6.0
PHP v 5.3.5 nts windows x86
Microsoft C++ 2008 redistributable
no fastcgi
Followed all the manual PHP configuration instructions very carefully, set php.ini directives, gave appropriate permissions to "IUSR_(machine)", set up web extensions etc. etc.
The final fix that made everything work... renamed 'php.ini' to 'php-cgi-fcgi.ini'
Hope this saves someone hours...
When executing:
cscript %windir%\system32\inetsrv\fcgico
nfig.js -add -section:"PHP" ^
More? -extension:php -path:"C:\PHP\php-cgi.exe"
You get this response:
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
C:\WINDOWS\system32\inetsrv\fcgiconfig.js(1348, 5) (null): 0xFFFFFFDF
Then check if in the C:\WINDOWS\system32\inetsrv\fcgiext.ini file the next text is present:
[Types]
php=c:\php\php-cgi.exe
[c:\php\php-cgi.exe]
QueueLength=999
MaxInstances=20
InstanceMaxRequests=10000
IdleTimeout=90
RequestTimeout=90
If not, add it, worked for me!
I am using Win 2003 Server SP2, IIS 6, Installing PHP 5.3.10 as FastCGI
If you continue to receive FastCGI could not proccess your request - Access Denied Error -5 check to make sure the IIS_WPG Group has Read, Read/Execute permission to the PHP installation directory and is inherited to the php-cgi.exe file.
Also, in researching this problem during my installation, I also found that you should have an entry in the IIS Web Extensions for the php-cgi.exe.
If you receive:
Input Error: There is no script engine for file extension ".js".
When executing:
cscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\PHP\php-cgi.exe"
Include the switch:
/e:jscript
Like this:
cscript /e:jscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\PHP\php-cgi.exe"
Worked on freshly installed XP Pro ENG SP3(updated).
I used Windows 2003 Server, IIS 6.0, MS SQL Server 2008, and PHP 5.3 along with FastCGI. If, after following the set up step-by-steps, you continually get a FastCGI 500 timeout error check your MS SQL Server PHP driver.
MS SQL Server PHP driver 3.0 which was updated on 04/18 requires you have the 2012 MS SQL Server Native Client (v 11). But if you are using MS SQL Server 2008 like I was you only have the 2008 MS SQL Server Native Client (v 10). For whatever reason I could not get the 2012 Native CLient to install on the OS even though it appeared MS's website said it should be able to.
So just downgrade to the MS SQL Server PHP driver 2.0. The site says it will be deprecated but at least you can get up and running for a while until you have to upgrade your OS and MS SQL Server.
This kinda drove me nuts for a few hours.
Using Win 2003 Server, IIS 6, PHP 5. If after running the command:
cscript fcgiconfig.js -add -section:"PHP" -extension:"php" -path:"C:\PHP\php-cgi.exe"
(with the right quotation as pointed in a previous note)
You get the following error/message:
C:\WINDOWS\system32\inetsrv\fcgiconfig.js(1326, 5) (null): 0xFFFFFFDF
It may be because you have a previous version of C:\WINDOWS\system32\inetsrv\fcgiext.ini. So backup the file and make a clean one with only an empty [types] section. Run the command again and it should work.
When installing PHP 5.3 on IIS by following the manual installation steps described here (install.windows.iis6) and here (install.windows.iis7) it is possible to get the following error from FastCGI:
HTTP Error 500.0 - Internal Server Error
Module: FastCgiModule
Notification: ExecuteRequestHandler
Handler: php-5.3.6
Error code: 0x800736b1
The reason this error happens is because PHP 5.3 is built by using Visual C++ 2008 compiler (VC9) and hence requires Visual C++ 2008 runtime to be installed on the machine. This error does not happen when PHP 5.3 is installed by Web Platform Installer or if you already have URL Rewrite module installed.
To fix the error download and install Visual C++ 2008 runtime from here:
http://www.microsoft.com/downloads/en/details.aspx?familyid=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en
(Make sure to use x86 version even if you have x64 environment)
Installing PHP 5.4 on Windows Server 2003 R2 Standard Edition with IIS 6:
Issue: After installing PHP I was getting 404 errors on all .php pages, even if I browsed from within IIS Manager.
Solution: Add a PHP Web Service Extension:
In IIS Manager, expande the local computer node on the left and right-click on Web Service Extensions. From the context menu select "Add a new Web service extension..."
In the New Web Service Extension dialog:
Extension name: PHP
Required files: Add... path to php.exe (eg C:\PHP\php.exe)
Set status of new web service extension to Allowed.
NOTE: Seems to work equally well if you use the path to php.exe or php-cgi.exe.
If you still receive 404 errors... try this...
I had to:
1) right click on My Computer, select Manage
2) open up "Services and Applications" -> "Internet Information Services" -> "Web Sites" -> mywebsite (where mywebsite could be "Default Web Site" or whatever my web site is named)
3) right-click on mywebsite and select Properties
choose the "Home Directory" tab, select Configuration... button
4) either select the .php extension and choose the Edit... button, or if .php isn't listed then press the Add... button
5) make the Executable C:\WINDOWS\system32\inetsrv\fcgiext.dll, the extension .php, and ensure Verbs are limited to GET,HEAD,POST, check the "Script engine" and "Verify that file exists" check boxes
Once I did this I at least now get the 500 fastcgi error
I used Windows 2003 Server, IIS 6.0, MS SQL Server 2008, and PHP 5.3 along with FastCGI. If, after following the set up step-by-steps, you continually get a FastCGI 500 timeout error check your MS SQL Server PHP driver.
MS SQL Server PHP driver 3.0 which was updated on 04/18 requires you have the 2012 MS SQL Server Native Client (v 11). But if you are using MS SQL Server 2008 like I was you only have the 2008 MS SQL Server Native Client (v 10). For whatever reason I could not get the 2012 Native CLient to install on the OS even though it appeared MS's website said it should be able to.
So just downgrade to the MS SQL Server PHP driver 2.0. The site says it will be deprecated but at least you can get up and running for a while until you have to upgrade your OS and MS SQL Server.
This kinda drove me nuts for a few hours.
If your PHP script displays `No input file specified' and you followed the instructions (for IIS 5.1 and windows XP) you might have to set up ACL on Windows\TEMP so that the IUSR accessing the page has right and write access on that folder.