# Multiple PHP versions on Windows: one site, one FastCGI version

> Run PHP 8.3 and 8.4 side by side on IIS with separate directories, FastCGI applications, site-level handlers and per-version php.ini.

**Tested on**

- Build: 26100.33650
- Edition: Standard / Datacenter
- Architecture: x64
- Evidence: E1
- Verified: 2026-10-29
- Test machine: PHP 8.4.27 FastCGI verified on VM 361 Windows 11 26H2; PHP 8.3 side-by-side pattern E1

## The short answer

PHP version is selected by the **handler's `scriptProcessor`**, not by the application pool. To run 8.3 and 8.4 side by side:

1. Install each NTS build in its own directory (`C:\PHP\8.3`, `C:\PHP\8.4`).
2. Each has its own `php.ini`.
3. Register each `php-cgi.exe` as a FastCGI application.
4. Give each site a site-level `*.php` handler pointing at that version.
5. Keep app pools separate for isolation, but do not expect the pool to choose PHP.

## Directory layout

```text
C:\PHP\8.3\php-cgi.exe
C:\PHP\8.3\php.ini
C:\PHP\8.4\php-cgi.exe
C:\PHP\8.4\php.ini
```

Do not put both versions in one folder or share `ext`. A missing/incorrect `extension_dir` is the usual “extension not found” cause.

## Register both FastCGI apps

```powershell
Import-Module WebAdministration
Add-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' `
  -Filter 'system.webServer/fastCgi' `
  -Value @{ fullPath = 'C:\PHP\8.3\php-cgi.exe' }
Add-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' `
  -Filter 'system.webServer/fastCgi' `
  -Value @{ fullPath = 'C:\PHP\8.4\php-cgi.exe' }
```

Both can exist; only the handler decides which one a request uses.

## Site-level handler

If the server already has a global `PHP_via_FastCGI` pointing at 8.4, a PHP 8.3 site can remove it and add its own:

```xml
<configuration>
  <system.webServer>
    <handlers>
      <remove name="PHP_via_FastCGI" />
      <add name="PHP83_via_FastCGI"
           path="*.php" verb="*"
           modules="FastCgiModule"
           scriptProcessor="C:\PHP\8.3\php-cgi.exe"
           resourceType="Either" />
    </handlers>
  </system.webServer>
</configuration>
```

Do **not** `<clear />` all handlers; that removes static content and breaks CSS/images. Remove only the PHP handler you are replacing.

The 8.4 site can keep the global handler or define `PHP84_via_FastCGI` explicitly. Explicitness is easier to audit.

## Per-version php.ini

Each version needs its own settings:

```ini
; C:\PHP\8.3\php.ini
cgi.fix_pathinfo=0
fastcgi.impersonate=1
date.timezone=UTC
extension_dir="ext"
expose_php=Off
```

If PHP loads the wrong ini, check `php --ini` / a phpinfo page. `PHPRC` can force a directory, but per-version directories + php-cgi next to its ini are simpler.

## Verify

```powershell
& C:\PHP\8.3\php-cgi.exe -v
& C:\PHP\8.4\php-cgi.exe -v
Get-WebConfiguration -PSPath 'MACHINE/WEBROOT/APPHOST' -Filter 'system.webServer/fastCgi' |
  Select-Object -ExpandProperty Collection
```

Create a site-specific `info.php` and confirm `PHP Version` and `Loaded Configuration File` on each site. Then remove the test page.

> **Caution: App pool is not a PHP version switch**
>
> Two app pools can run the same PHP binary. If both sites inherit the same `*.php` handler, they both use that `scriptProcessor`. The pool only controls identity/process isolation.

## Upgrade path

1. Add the new version beside the old one.
2. Test one site with a site-level handler.
3. Compare extensions and `php.ini`.
4. Move sites one at a time.
5. Keep the old version until rollback is no longer needed; then remove its FastCGI app and directory.

## Lab boundary

PHP 8.4.27 NTS + IIS FastCGI was verified on VM 361. The 8.3 side-by-side setup is E1; use the same procedure on Server 2025 and record both phpinfo pages before calling it E2.

## Sources

- [PHP — Windows downloads](https://windows.php.net/downloads/releases/)
- [PHP — Configuration file](https://www.php.net/manual/en/configuration.file.php)
- [Microsoft Learn — FastCGI](https://learn.microsoft.com/en-us/iis/configuration/system.webserver/fastcgi/)

---

Source: https://windows.homes/en/server/runtimes/php-multi-version/
