How to Properly Uninstall PHP 5.3 Installed via Web Platform Installer on Windows Server 2008 R2


1 views

When you install PHP through Microsoft's Web Platform Installer (WPI), it doesn't always create standard Windows uninstall entries. This is particularly true for older versions like PHP 5.3 on Windows Server 2008 R2. The WebPI 3.0.x installation method leaves you without a clean uninstall path through Programs and Features.

Here's the complete process I've verified on multiple production servers:

  1. Stop IIS services:
    net stop w3svc /y
  2. Remove PHP handler mappings:
    Navigate to %windir%\system32\inetsrv\config\applicationHost.config and delete all PHP 5.3 related handler mappings like:

    <add name="PHP53_via_FastCGI" 
         path="*.php" 
         verb="*" 
         modules="FastCgiModule" 
         scriptProcessor="C:\Program Files (x86)\PHP\v5.3\php-cgi.exe" 
         resourceType="Either" />
  3. Delete installation directory:
    rmdir /s /q "C:\Program Files (x86)\PHP\v5.3"
  4. Clean registry entries (backup first!):
    reg delete "HKLM\SOFTWARE\PHP" /v "5.3" /f

If you have PHP Manager installed (also via WebPI), you'll need to:

msiexec /x {YOUR-PHP-MANAGER-GUID} /quiet

Find the GUID using:

wmic product where "name like 'PHP Manager%'" get identifyingnumber

After uninstallation:

  1. Check environment variables:
    echo %PATH% | find "php"
  2. Verify IIS handler mappings:
    appcmd list config -section:system.webServer/handlers | find "php"

For automated deployments, you can chain these commands in a batch file:

@echo off
:: Stop IIS
net stop w3svc /y

:: Remove directory
if exist "C:\Program Files (x86)\PHP\v5.3" (
    rmdir /s /q "C:\Program Files (x86)\PHP\v5.3"
)

:: Clean registry
reg delete "HKLM\SOFTWARE\PHP" /v "5.3" /f

:: Restart IIS
net start w3svc

When PHP is installed through Microsoft's Web Platform Installer (WPI), it often doesn't register properly in Windows' "Programs and Features" control panel. This leaves administrators with no clean uninstallation path when needing to remove specific versions (like PHP 5.3 while preserving PHP 5.2).

Here's the correct procedure I've verified on Windows Server 2008 R2:

1. Stop all PHP-related services:
   net stop w3svc
   net stop php-cgi

2. Delete the PHP version folder:
   rmdir /s /q "C:\Program Files (x86)\PHP\v5.3"

3. Clean registry entries (backup first!):
   reg delete "HKLM\SOFTWARE\PHP" /v "5.3" /f
   reg delete "HKLM\SOFTWARE\Wow6432Node\PHP" /v "5.3" /f

4. Remove FastCGI configuration from applicationHost.config:
   %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /-"[fullPath='C:\Program Files (x86)\PHP\v5.3\php-cgi.exe']" /commit:apphost

If you're using PHP Manager for IIS:

1. Open IIS Manager
2. Navigate to your server node
3. Double-click PHP Manager
4. Click "Register new PHP version" and remove any 5.3 references
5. Check handler mappings and remove orphaned PHP 5.3 entries

After completing the uninstallation:

1. Check remaining PHP versions:
   where php

2. Verify IIS configuration:
   appcmd.exe list config -section:system.webServer/fastCgi

3. Test web applications to ensure no PHP 5.3 dependencies remain

For automated environments, here's a PowerShell script I've used successfully:

# Stop services
Stop-Service -Name W3SVC -Force
Stop-Process -Name php-cgi -Force -ErrorAction SilentlyContinue

# Remove files
Remove-Item -Path "${env:ProgramFiles(x86)}\PHP\v5.3" -Recurse -Force

# Clean registry
Remove-ItemProperty -Path "HKLM:\SOFTWARE\PHP" -Name "5.3" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\PHP" -Name "5.3" -ErrorAction SilentlyContinue

# Update IIS configuration
$appHostConfig = "$env:windir\system32\inetsrv\config\applicationHost.config"
$config = [xml](Get-Content $appHostConfig)
$node = $config.SelectSingleNode("//fastCgi/application[@fullPath='C:\Program Files (x86)\PHP\v5.3\php-cgi.exe']")
if ($node -ne $null) {
    [void]$node.ParentNode.RemoveChild($node)
    $config.Save($appHostConfig)
}

Before proceeding with uninstallation:

  • Create a system restore point
  • Document all PHP 5.3-specific application settings
  • Verify no critical applications depend on PHP 5.3
  • Consider testing in a staging environment first