Docs / Windows Server / How to Install PHP on IIS with Windows Server

How to Install PHP on IIS with Windows Server

By Admin · Mar 2, 2026 · Updated Apr 23, 2026 · 24 views · 3 min read

How to Install PHP on IIS with Windows Server

Running PHP on IIS is a great option for hosting PHP applications on your Kazepute Breeze. IIS integrates with PHP through FastCGI, providing excellent performance and stability. This guide covers installing PHP on IIS and configuring it for production use.

Prerequisites

  • A Kazepute Breeze running Windows Server 2019 or 2022
  • IIS installed with CGI module enabled
  • Administrator access

Step 1: Install IIS with CGI Support

If IIS is not already installed, add it with CGI support:

# Install IIS with CGI module
Install-WindowsFeature -Name Web-Server, Web-CGI -IncludeManagementTools

# Verify CGI is installed
Get-WindowsFeature Web-CGI

Step 2: Download and Install PHP

Download the Non-Thread Safe (NTS) version of PHP for use with FastCGI:

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

# Download PHP (update URL for the latest version)
Invoke-WebRequest -Uri "https://windows.php.net/downloads/releases/php-8.3.0-nts-Win32-vs16-x64.zip" -OutFile "C:\PHP\php.zip"

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

# Add PHP to system PATH
[Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";C:\PHP", "Machine")

Step 3: Configure PHP

Create the PHP configuration file:

# Copy the production config template
Copy-Item "C:\PHP\php.ini-production" "C:\PHP\php.ini"

Edit C:\PHP\php.ini and adjust the following settings:

; Set extension directory
extension_dir = "C:\PHP\ext"

; Enable commonly needed extensions
extension=curl
extension=gd
extension=mbstring
extension=mysqli
extension=openssl
extension=pdo_mysql
extension=pdo_sqlsrv
extension=sqlsrv
extension=zip

; Performance settings
max_execution_time = 300
memory_limit = 256M
post_max_size = 64M
upload_max_filesize = 64M

; Error logging (disable display in production)
display_errors = Off
log_errors = On
error_log = "C:\PHP\php_errors.log"

; Session configuration
session.save_path = "C:\Windows\Temp"

; Timezone
date.timezone = "UTC"

Step 4: Register PHP with IIS

Configure IIS to use PHP via FastCGI:

# Register PHP as a FastCGI handler
Add-WebConfiguration -Filter /system.webServer/fastCgi -PSPath IIS:\ -Value @{
    fullPath = "C:\PHP\php-cgi.exe"
    maxInstances = 4
    idleTimeout = 300
    activityTimeout = 600
    requestTimeout = 600
}

# Map .php files to the FastCGI handler
New-WebHandler -Name "PHP_FastCGI" -Path "*.php" -Verb "*" -Modules "FastCgiModule" -ScriptProcessor "C:\PHP\php-cgi.exe" -ResourceType File

# Set index.php as a default document
Add-WebConfigurationProperty -Filter /system.webServer/defaultDocument/files -PSPath IIS:\ -Name collection -Value @{value = "index.php"}

Step 5: Test PHP

Create a test file to verify the installation:

# Create a PHP info page
Set-Content -Path "C:\inetpub\wwwroot\info.php" -Value "<?php phpinfo(); ?>"

# Test PHP from the command line
C:\PHP\php.exe -v
C:\PHP\php.exe -m

Navigate to http://your-breeze-ip/info.php in a browser. You should see the PHP information page. Remove this file after testing.

Install SQL Server Extensions for PHP

If you are using Microsoft SQL Server, install the PHP drivers:

# Download Microsoft ODBC Driver for SQL Server (required)
# Then download the sqlsrv and pdo_sqlsrv DLLs from PECL
# Place them in C:\PHP\ext\

# Enable in php.ini
# extension=sqlsrv
# extension=pdo_sqlsrv

Best Practices

  • Always use the Non-Thread Safe (NTS) version of PHP with IIS FastCGI.
  • Set display_errors = Off in production and use error_log instead.
  • Remove info.php and any test files from production sites.
  • Keep PHP updated to the latest stable version for security patches.
  • Use OPcache (built into PHP) for improved performance — enable it in php.ini.
  • Configure separate application pools for PHP sites running different PHP versions.

Was this article helpful?