Skip to content

PHP 8.4 on IIS FastCGI: install it without php-fpm myths

Verified 2 min read

Install PHP 8.4 NTS on Windows, add IIS FastCGI and the handler, set a safe php.ini, verify phpinfo, and remove the lab page afterwards.

Tested onStandard / Datacenter · Build 26100.33650 · x64
E1
Build
26100.33650
Edition
Standard / Datacenter
Architecture
x64
Support
Documentation (E1)
Evidence
E1Official documentation
Verified
2026-10-29
Test machine
PHP 8.4.27 NTS + IIS FastCGI verified on VM 361 Windows 11 26H2; Server 2025 role/cmdlet E1
Page type
Task
PHP 8.4.27 phpinfo page served by IIS FastCGI on Windows 11 26H2, showing Server API CGI/FastCGI and the loaded php.ini.
VM 361: PHP 8.4.27 NTS served by IIS FastCGI, Server API CGI/FastCGI, loaded C:\PHP\8.4\php.ini. The host is Windows 11 26H2; Server 2025 role steps remain E1.

On Windows, PHP officially runs under FastCGI/CGI, not php-fpm. There is no official Windows php-fpm build to install.

The working stack is:

  1. IIS + CGI/FastCGI role service.
  2. PHP NTS Windows build + VC++ runtime.
  3. php.ini with fastcgi.impersonate=1, cgi.fix_pathinfo=0.
  4. IIS FastCGI application + *.php handler.
  5. A test page, then remove phpinfo().

Server 2025:

Terminal window
Install-WindowsFeature Web-CGI

Windows client lab (what VM 361 used):

Terminal window
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI -All -NoRestart

Restart IIS (iisreset) or the W3SVC service if the handler does not appear.

Use the NTS (Non-Thread Safe) zip for FastCGI. In this lab:

  • php-8.4.27-1-nts-Win32-vs17-x64.zip
  • extracted to C:\PHP\8.4
  • php.exe -v returned PHP 8.4.27 (cli) (NTS Visual C++ 2022 x64)

Verify the SHA-256 against sha256sum.txt from the same download directory. Do not use a random “PHP for Windows” repack.

The PHP binaries need the Visual C++ 2015–2022 x64 Redistributable. Without it, php.exe exits with 0xC0000135 (missing DLL). Install it, then retest php.exe -v.

Copy php.ini-development to php.ini and set at least:

fastcgi.impersonate=1
cgi.fix_pathinfo=0
date.timezone=UTC
extension_dir="ext"
expose_php=Off

For production also:

display_errors=Off
log_errors=On
error_log="C:\PHP\logs\php-error.log"

Do not enable every extension. Add mysqli, pdo_mysql, curl, mbstring, openssl only when the app needs them, and verify with php -m.

Use WebAdministration (recommended over hand-quoting appcmd):

Terminal window
Import-Module WebAdministration
Add-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' `
-Filter 'system.webServer/fastCgi' `
-Value @{ fullPath = 'C:\PHP\8.4\php-cgi.exe' }
Add-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' `
-Filter 'system.webServer/handlers' `
-Value @{
name = 'PHP_via_FastCGI'; path = '*.php'; verb = '*';
modules = 'FastCgiModule';
scriptProcessor = 'C:\PHP\8.4\php-cgi.exe';
resourceType = 'Either'
}

Then:

Terminal window
& 'C:\PHP\8.4\php-cgi.exe' -v
Set-Content C:\inetpub\lab\info.php '<?php phpinfo();' -Encoding ASCII
Invoke-WebRequest http://localhost:8080/info.php -UseBasicParsing | Select-Object StatusCode

Expected: 200, and phpinfo shows Server API: CGI/FastCGI, Loaded Configuration File: C:\PHP\8.4\php.ini.

  • The app pool identity needs read/execute on C:\PHP\8.4 and the site root.
  • It should not have write access to the PHP directory.
  • Uploads get a separate directory with modify rights only there.
  • Do not run the app pool as LocalSystem to “make PHP work”.
  • Remove info.php after testing; phpinfo discloses paths, modules and configuration.
  • expose_php=Off removes the X-Powered-By version hint.
  • Keep display_errors=Off in production; log instead.
  • cgi.fix_pathinfo=0 avoids the classic path-resolution issue, but it is not a substitute for upload validation.
  • Patch PHP on a schedule; an EOL PHP branch gets no security fixes.

Verified on VM 361: PHP 8.4.27 NTS, IIS FastCGI, info.php returned 200. That is E2 for the Windows 11 FastCGI mechanics, not a Server 2025 reproduction. Server 2025 uses Install-WindowsFeature Web-CGI; the handler configuration is the same family.

Sources