How to install PHP on IIS 10 in Windows Server

If you open a .php file on an IIS website and PHP is not properly installed or mapped to FastCGI, IIS returns an HTTP 500 Internal Server Error in your browser.

Internal Server Error 500

Note: Always install the latest PHP 8.x (PHP 8.4 or newer, Non-Thread Safe x64) build directly via FastCGI on IIS 10 (Microsoft Web Platform Installer is retired).

Step 1: Enable IIS and the CGI Feature

  1. Open Server Manager on Windows Server 2025 / 2022 and choose Add roles and features.
  2. Select Web Server (IIS).
  3. Expand Web Server > Application Development and check CGI (this enables FastCGI support in IIS).
  4. Complete the installation wizard.

Step 2: Install Visual C++ Redistributable

Modern Windows PHP 8.x builds require the Microsoft Visual C++ Redistributable (x64, Visual Studio 2015–2022 / latest supported release):

  1. Download and install the x64 vc_redist.x64.exe package from Microsoft Learn.

Step 3: Download and Extract PHP 8.4 / Latest PHP 8.x (NTS)

  1. Go to windows.php.net/download.
  2. Download the VS17 x64 Non Thread Safe (NTS) .zip package for PHP 8.4 (or the latest PHP 8.x release — IIS FastCGI requires the NTS build).
  3. Extract the archive to C:\PHP.
  4. Copy C:\PHP\php.ini-production to C:\PHP\php.ini and adjust these essential IIS settings inside php.ini:
cgi.fix_pathinfo=0
fastcgi.impersonate=1
extension_dir = "ext"
date.timezone = "Europe/Amsterdam"

(Uncomment the extensions you need, such as extension=curl, extension=mbstring, extension=mysqli, extension=openssl, and extension=pdo_mysql.)

Step 4: Configure IIS FastCGI Handler Mapping

  1. Open IIS Manager (inetmgr).
  2. Select your server node (or specific website) and double-click Handler Mappings.
  3. Click Add Module Mapping... in the Actions pane and enter:
    • Request path: *.php
    • Module: FastCgiModule
    • Executable: C:\PHP\php-cgi.exe
    • Name: PHP_FastCGI
  4. Click OK and confirm Yes when asked to create a FastCGI application entry.
  5. (Optional) Double-click Default Document in IIS Manager and add index.php if not present.

Step 5: Test PHP with info.php

Create C:\inetpub\wwwroot\info.php with the following contents:

<?php
phpinfo();

Open http://localhost/info.php in your browser to verify PHP 8.x loads cleanly under IIS 10.

Security Warning: Immediately delete info.php once you have verified your installation (Remove-Item C:\inetpub\wwwroot\info.php). Leaving phpinfo() accessible leaks server paths, PHP versions, and environment variables.

User