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

> 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 on**

- Build: 26100.33650
- Edition: Standard / Datacenter
- Architecture: x64
- Evidence: E1
- 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

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.

## The short answer

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()`.

## Install the IIS side

Server 2025:

```powershell
Install-WindowsFeature Web-CGI
```

Windows client lab (what VM 361 used):

```powershell
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI -All -NoRestart
```

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

## Download PHP

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`.

## php.ini

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

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

For production also:

```ini
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`.

## FastCGI + handler

Use WebAdministration (recommended over hand-quoting `appcmd`):

```powershell
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:

```powershell
& '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**.

## Permissions

- 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”.

## Security

- 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.

> **Caution: No Windows php-fpm**
>
> If a guide tells you to install php-fpm on Windows, it is either using a third-party build or confusing FastCGI with FPM. This page uses the official Windows PHP + IIS FastCGI path.

## Lab note

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

- [PHP — Windows downloads](https://windows.php.net/downloads/releases/)
- [PHP manual — Install on Windows](https://www.php.net/manual/en/install.windows.php)

---

Source: https://windows.homes/en/server/web/iis-php/
