IIS Support For PHP
Install Latest PHP Version (8.2)
This version of PHP requires C++ Redistributable for VS 2019 (at least)
Microsoft Visual C++ Redistributable for Visual Studio 2022
Download for corresponding OS.
You can also use this link:
Latest supported Visual C++ Redistributable downloads
The Visual C++ Redistributable installs Microsoft C and C++ (MSVC) runtime libraries. These libraries are required by…
Download corresponding OS and use the Non Thread Safe.
Unzip it under “c:/php”:
Testing PHP Installation
Check installation by opening command prompt and change directory to “c:/php”
Microsoft Windows [Version 10.0.17763.3770]
(c) 2018 Microsoft Corporation. All rights reserved.
PHP 8.2.1 (cli) (built: Jan 3 2023 23:36:33) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.1, Copyright (c) Zend Technologies
We need CGI module.
If you are installing IIS for the first time you can use the following command:
Install-WindowsFeature -name Web-WebServer, Web-CGI -IncludeManagementTools
We must indicate IIS where is the CGI for ‘.php’ files. All PHP code will be executed by this CGI.
- Open IIS Manager, select the hostname of your computer in the Connections panel, and then doubleclick Handler Mappings.
- In the Action panel, click Add Module Mapping.
- In Request path, type “*.php”.
- From the Module menu, select FastCgiModule.
- In the Executable box, type the full path to Php-cgi.exe, for example C:\PHP\Php-cgi.exe.
- In Name, type a name for the module mapping, for example FastCGI.
Default Document Configuration
Add “index.php” and “default.php” into “Default Document” module. So, if anyone visits
“localhost/wordpress”, if there is a file called with one of those names, it will be automatically served.
- Select the hostname of your computer in the Connections panel, and double-click Default Document.
- In the Action panel, click Add. Type Index.php in the Name box, and then click OK.
- Click Add again. Type Default.php in the Name box, and then click OK.
PHP Manager Extension
PHP Manager extension help us to configure IIS for PHP.
Before using it we need to make sure we have that file. Let us go to where we unzipped PHP content. In our case C:/php
Make a copy of “php.ini-production”, just to have it.
Rename “php.ini-production” => “php.ini”
Close IIS Manager and open it again, you should now see a new icon:
Open the module and “View recommendations”
You could check all boxes, I am going to check the followings:
WinCache extension [Optional]
The Windows Cache Extension for PHP is a PHP accelerator that is used to significantly increase the speed of PHP applications running on the Windows® operating system.
Download WinCache Extension for PHP
Extract files in “C:\php\ext”:
Enable extension in the “php.ini”
Environmental Variables [Optional]
Open the environmental Variables
Add the path where php is.
In my case “C:\php”:
Testing PHP Inside IIS
1. Open a text editor, for example Notepad, as Administrator.
2. In a new file, type the following text:
<?php phpinfo(); ?>
3. Save the file as C:\inetpub\wwwroot\Phpinfo.php.
4. Open a browser and enter the following URL:
A nicely formatted webpage is displayed showing the current PHP settings.
- Configure a PHP Website on IIS | Microsoft Learn