PHPIISFastCGI7 min read

Install PHP on IIS

Install PHP on IIS with FastCGI to run WordPress and PHP applications.


PHP on IIS with FastCGI lets you run PHP applications like WordPress, Laravel, or any framework on Windows Server.

Step 1 — Install IIS with CGI

powershell
Install-WindowsFeature Web-Server, Web-CGI, Web-Mgmt-Console -IncludeManagementTools

Step 2 — Download PHP

powershell
# Create directory
New-Item -Path C:\PHP -ItemType Directory

# Download PHP (Non-Thread Safe for IIS)
Invoke-WebRequest -Uri "https://windows.php.net/downloads/releases/php-8.3.8-nts-Win32-vs16-x64.zip" -OutFile "C:\temp\php.zip"

# Extract
Expand-Archive -Path "C:\temp\php.zip" -DestinationPath "C:\PHP"

Step 3 — Configure PHP

powershell
# Create php.ini from template
Copy-Item C:\PHP\php.ini-production C:\PHP\php.ini

Edit C:\PHP\php.ini:

ini
extension_dir = "C:\PHP\ext"

; Common extensions
extension=curl
extension=gd
extension=mbstring
extension=mysqli
extension=openssl
extension=pdo_mysql
extension=zip

; Configuration
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
memory_limit = 256M
date.timezone = UTC

Step 4 — Add PHP to PATH

powershell
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\PHP", "Machine")

Step 5 — Configure FastCGI in IIS

powershell
# Register PHP as FastCGI handler
New-WebHandler -Name "PHP-FastCGI" -Path "*.php" -Verb "GET,HEAD,POST" -Modules "FastCgiModule" -ScriptProcessor "C:\PHP\php-cgi.exe" -ResourceType File

# Configure FastCGI
Add-WebConfiguration -Filter /system.webServer/fastCgi -PSPath IIS:\ -Value @{fullPath='C:\PHP\php-cgi.exe'}

Step 6 — Verify installation

Create C:\inetpub\wwwroot\info.php:

powershell
Set-Content -Path "C:\inetpub\wwwroot\info.php" -Value "<?php phpinfo();"

Access http://YOUR_IP/info.php. Then remove it:

powershell
Remove-Item C:\inetpub\wwwroot\info.php

Step 7 — Install WordPress

powershell
# Download WordPress
Invoke-WebRequest -Uri "https://wordpress.org/latest.zip" -OutFile "C:\temp\wordpress.zip"
Expand-Archive -Path "C:\temp\wordpress.zip" -DestinationPath "C:\inetpub"

# Create site in IIS
New-IISSite -Name "WordPress" -PhysicalPath "C:\inetpub\wordpress" -BindingInformation "*:80:mydomain.com"

PHP on IIS lets you run web applications on your Baires Host Windows VPS with native performance.


Was this guide helpful?