WordPress on IIS and Windows Server: a complete setup guide

Install WordPress on IIS on Windows Server 2019, 2022 or 2025: PHP through FastCGI, a MySQL or MariaDB database, pretty permalinks with web.config, and file permissions that let WordPress upload without opening the whole site.

Cover image: WordPress on IIS and Windows Server: a complete setup guide

Key takeaways

  • WordPress runs well on IIS with PHP over FastCGI and a MySQL or MariaDB database on the same server.
  • Pretty permalinks need the URL Rewrite module and a short rule in web.config, because IIS ignores .htaccess.
  • Give the site's application pool identity write access to wp-content only, not the whole site.
  • Keep the database on loopback with its own user, and put the site on HTTPS before you go live.

WordPress on IIS on Windows Server works the same as on Linux once four things are in place: PHP running through IIS FastCGI, a MySQL or MariaDB database, the URL Rewrite module for permalinks, and NTFS permissions that let the site's application pool identity write to wp-content. This guide walks through each part on IIS 10, with commands you can paste. It assumes a site per WordPress install and one application pool per site.

What you need

  • Windows Server 2019, 2022 or 2025 with IIS and the CGI role service.
  • A supported PHP 8 version, installed for FastCGI. If you have not done this yet, follow how to install PHP on IIS first and come back.
  • The PHP extensions WordPress uses: mysqli, curl, mbstring, openssl, fileinfo, intl, exif, and gd or imagick for image resizing.
  • The URL Rewrite module from Microsoft.
  • MySQL or MariaDB. Check the current minimum versions on wordpress.org's requirements page before you choose.

Step 1: install the database server

Both MySQL and MariaDB ship Windows MSI packages that install a Windows service. During setup, keep the server listening on 127.0.0.1 unless another machine really needs it, and set a strong root password. If you are choosing between engines, our comparison MySQL vs SQL Server for websites on Windows explains why WordPress needs MySQL or MariaDB in practice.

Create a database and a user that can only touch that database:

CREATE DATABASE wp_example CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_example'@'localhost' IDENTIFIED BY 'a-long-random-password';
GRANT ALL PRIVILEGES ON wp_example.* TO 'wp_example'@'localhost';
FLUSH PRIVILEGES;

Never point WordPress at the root account.

Step 2: create the site and its pool

Import-Module WebAdministration

New-Item -ItemType Directory C:\sites\example.com | Out-Null
New-WebAppPool -Name 'example.com'
Set-ItemProperty IIS:\AppPools\example.com -Name managedRuntimeVersion -Value ''

New-Website -Name 'example.com' -PhysicalPath 'C:\sites\example.com' `
  -HostHeader 'example.com' -Port 80 -ApplicationPool 'example.com'
New-WebBinding -Name 'example.com' -Protocol http -Port 80 -HostHeader 'www.example.com'

# Run anonymous requests as the pool identity, not the shared IUSR account
& "$env:windir\system32\inetsrv\appcmd.exe" set config 'example.com' `
  /section:anonymousAuthentication /userName:"" /commit:apphost

The last command matters for permissions: with it, every PHP request runs as IIS AppPool\example.com, so you can grant rights to that one account. IIS application pool identity explained covers why.

Map *.php to your PHP version on this site and add index.php as a default document, as shown in the PHP guide.

Step 3: download WordPress

Invoke-WebRequest https://wordpress.org/latest.zip -OutFile $env:TEMP\wp.zip
Expand-Archive $env:TEMP\wp.zip -DestinationPath $env:TEMP\wp -Force
Copy-Item $env:TEMP\wp\wordpress\* C:\sites\example.com -Recurse

Before you run the installer, it is worth checking the zip against the checksum published on wordpress.org.

Step 4: set file permissions

WordPress needs to read every file and to write in wp-content (uploads, plugin and theme updates, caches). It does not need to write anywhere else.

$id = 'IIS AppPool\example.com'
icacls 'C:\sites\example.com' /grant "${id}:(OI)(CI)RX"
icacls 'C:\sites\example.com\wp-content' /grant "${id}:(OI)(CI)M"

During the web installer, WordPress will also want to create wp-config.php in the site root. Either create it yourself from wp-config-sample.php (recommended), or grant write on the root for the install only and take it back afterwards.

Updating WordPress core from the dashboard writes outside wp-content. If you keep the root read-only, update core with WP-CLI as an administrator, or open write access for the update window.

Also block PHP execution in uploads. A web.config in wp-content\uploads:

<configuration>
  <system.webServer>
    <handlers>
      <remove name="PHP84_FastCGI" />
    </handlers>
  </system.webServer>
</configuration>

Use the handler name you created for the site. With the handler removed, a .php file uploaded by an attacker is not executed.

IIS does not read the .htaccess file WordPress expects. Put this in C:\sites\example.com\web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.php" />
      </files>
    </defaultDocument>
    <rewrite>
      <rules>
        <rule name="WordPress" patternSyntax="Wildcard">
          <match url="*" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Then choose Settings → Permalinks → Post name in WordPress. If WordPress can write web.config and URL Rewrite is installed, it can add the rule itself; with the read-only root above, add it by hand.

Step 6: run the installer and switch to HTTPS

Browse to http://example.com/, enter the database name, user and password, and finish the install. Then get a certificate and redirect HTTP to HTTPS before you publish anything: see free SSL certificates on IIS with Let's Encrypt and redirect HTTP to HTTPS on IIS. Update Settings → General so both URLs start with https://.

Hardening worth doing

  • In wp-config.php: define('DISALLOW_FILE_EDIT', true); to turn off the theme and plugin editor.
  • Deny direct access to wp-config.php and xmlrpc.php if you do not use XML-RPC, with a URL Rewrite rule returning 403 or a requestFiltering hidden segment.
  • Set upload_max_filesize and post_max_size in php.ini to what your media actually needs.
  • Back up the files and the database on a schedule, and test a restore.

FAQ

Can WordPress run on IIS without URL Rewrite?

Yes, but only with "Plain" permalinks (?p=123) or the index.php/ prefix. Pretty permalinks need URL Rewrite.

Can WordPress use SQL Server instead of MySQL?

Not officially. WordPress core targets MySQL and MariaDB. Third-party adapters exist, but plugins that write their own SQL often break.

Why do media uploads fail with "Unable to create directory"?

The pool identity has no write access to wp-content\uploads. Grant Modify on wp-content to IIS AppPool\<pool>, and check that anonymous authentication uses the pool identity.

Is WordPress on IIS slower than on Linux?

We have not measured that, so we will not claim a number. Enabling OPcache, keeping PHP processes warm and using a page cache plugin matter more than the web server.

In Zopanel for Windows

Zopanel does all of the above in one click: create a PHP 8.3 or 8.4 site, click Install WordPress, and the panel downloads WordPress, creates the database, writes wp-config.php, sets the permalink rules and runs everything under the site's own pool identity. This is available on Server 2019, 2022 and 2025, as are updates with a backup and automatic rollback, staging, mass updates and one-click hardening. The WordPress page and object cache option is experimental. See the WordPress docs and the WordPress feature page. The Free plan runs 1 server and 10 sites: download, or see pricing.