This is an old revision of the document!
Table of Contents
Installing PHP 8.1.12 for Windows IIS 10
Download the Non-Threadsafe x64 (64-bit) version of PHP 8.1.12 (or latest version) from here https://windows.php.net/download#php-8.1
Unblock the Zip File (Properties - Clear Check Box - “This file came from another computer and is blocked . . . etc” Click OK.
Unzip the Zip File to php_8_1
Using Windows file explorer, copy and paste the “php_8_1” directory (including its contained files and subdirectories) to your new and separate PHP path, such as c:\php_8_1
Using Notepad++ or similar advanced text editor, in the root of the php_8_1 directory, find and open the file “php.ini-production” and save as a new file named “php.ini” without the quotes.
Here is a snapshot of the Windows PHP8 download page which also lists the other requirements such as the Visual C++ Redistributable that must be installed on the Windows server system.
Configure Handler Mappings for FastCGI Module in IIS Manager
- Start IIS Manager by clicking on Start, Programs, Administrative Tools, and then Internet Information Services (IIS) Manager.
- From the IIS Manager, click on the hostname of your server in the Connections panel on the left.
- Double-click on the Handler Mappings icon. Insert a screen capture here depicting IIS and handler mappings
- From the Handler Mappings Actions panel, click on Add Module Mapping.
- Type the following information into the appropriate text boxes, and then click OK. Request path: *.php then Module : FastCGImodule then Executable: C:\php_8\php-cgi.exe then Name: FastCGI
- Click OK, and then click Yes.
Configure the php.ini File
- In the c:\php_8_1 folder, open the php.ini-production file using a good text editor like Notepad++ and then “save as” the contents of this file using the new file name “php.ini” and then close (x) both the php.ini-production file (tab) and the new php.ini file (tab) from within Notepad++.
- Re-open the php.ini file using Notepad++ text editor and then un-comment and modify certain settings within php.ini as follows:
- Set fastcgi.impersonate = 1 ;REMARK FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.
- Set cgi.fix_pathinfo = 0 ;REMARK The cgi.fix_pathinfo provides PATH_INFO/PATH_TRANSLATED support for Common Gateway Interface (CGI). Setting this to 1 will cause PHP CGI to fix its paths to conform to the specification.
- Set cgi.force_redirect = 0
- Set open_basedir = a path pointing to a folder or network path where the content of the Web site(s) is located. (Such as c:\hostdata), or just leave it commented like this “;open_basedir =” without the quotes
- Set extension_dir to point to a location where PHP extensions reside. This is typically extension_dir = “./ext” However, per remarks in the “php.ini-production” file in both PHP7 and PHP8 it says for “Windows” set it instead as follows: extension_dir = “ext”
- Set error_log=“C:php_errors.log” ;REMARK This can help with troubleshooting. Alternatively, set error_log = “c:\php\logs\errors_log” and make a new sub-folder in c:php named “logs” and grant the sub-folder “logs” full control write access for both IUSR and IIS_USERS.
- Enable the required PHP extension by un-commenting the appropriate lines within the extensions section of the php.ini file. See a further discussion of which extensions to enable.