A PowerShell script to automate the complete setup of IIS with PHP support via FastCGI on Windows 11 / Server.
Perfect for quickly deploying a PHP-based webmail (like Roundcube) or any PHP website with a custom domain.
- ✅ Automatic IIS installation – enables required Windows features (IIS-WebServerRole, IIS-CGI)
- ✅ Smart PHP download – detects the correct compiler version (vs16/vs17) based on PHP version
- ✅ Visual C++ Redistributable check – installs the latest VC++ 2015-2022 x64 if missing
- ✅ Idempotent – safe to run multiple times; skips already completed steps
- ✅ FastCGI configuration – registers PHP as a FastCGI application and adds the
*.phphandler - ✅ IIS application pool & website creation – with customizable name, host header, port, and physical path
- ✅ Folder permissions – automatically grants read/execute access to
IUSR - ✅ Test page – creates a simple
phpinfo()file to verify the setup - ✅ Works with PowerShell 7.5+ – uses Windows PowerShell compatibility for IIS cmdlets
- Windows 11 / Windows Server 2019 or later
- Administrator privileges
- Internet connection (to download PHP and VC++ Redistributable)
-
Clone or download this repository.
-
Open PowerShell 7.5+ as Administrator.
-
Run the script:
.\Setup-IIS-PHP.ps1