NewCode CLOUD — 20% off your first month on all cloud VPSClaim

Host a Website on Windows Server with IIS and a Free Let's Encrypt Certificate

IIS (Internet Information Services) is the web server built into Windows Server. It is the natural choice for ASP.NET and .NET applications, and it also runs PHP sites, static sites and reverse proxies. This guide installs IIS, sets up a site with a domain name, adds a free Let’s Encrypt certificate that renews automatically, and covers the settings that matter in production.

Step 1: Install IIS

Open PowerShell as Administrator:

Install-WindowsFeature -Name Web-Server -IncludeManagementTools

For ASP.NET on .NET Framework, add:

Install-WindowsFeature Web-Asp-Net45, Web-Net-Ext45, Web-ISAPI-Ext, Web-ISAPI-Filter

Useful extras:

Install-WindowsFeature Web-Http-Redirect, Web-Dyn-Compression, Web-Request-Monitor, Web-Http-Tracing

Browse to http://YOUR_SERVER_IP — the IIS welcome page should appear. If not, check the firewall rule World Wide Web Services (HTTP Traffic-In) is enabled.

Step 2: Create a site

  1. Create the folder: C:\inetpub\sites\example.com, and put an index.html in it.
  2. Open IIS Manager (inetmgr) → Sites → Add Website:
    • Site name: example.com
    • Physical path: C:\inetpub\sites\example.com
    • Binding: type http, IP All Unassigned (or a specific IP), port 80, host name example.com
  3. Add a second binding for www.example.com (right-click the site → Edit Bindings).

PowerShell equivalent:

Import-Module WebAdministration
New-Item -ItemType Directory C:\inetpub\sites\example.com
New-Website -Name "example.com" -PhysicalPath "C:\inetpub\sites\example.com" -HostHeader "example.com" -Port 80
New-WebBinding -Name "example.com" -HostHeader "www.example.com" -Port 80 -Protocol http

The host name in the binding is what lets many sites share one IP and port. Make sure the domain’s A record points to the server — see DNS records explained.

To bind a site to a specific additional IP, first add the IP to Windows, then choose it in the binding.

Step 3: Application pools

Each site should have its own application pool — a separate worker process with its own identity. If one site crashes or is compromised, others are not affected.

IIS creates a pool with the site’s name automatically. Check in Application Pools:

  • .NET CLR version: “No Managed Code” for .NET Core/.NET 5+ and PHP; “v4.0” for .NET Framework apps.
  • Identity: ApplicationPoolIdentity (default) is a low-privilege virtual account — keep it.
  • Recycling: the default recycles every 1,740 minutes (29 hours). Many admins change it to a fixed quiet time (e.g. 04:00) under Advanced Settings → Recycling.
  • Idle time-out: 20 minutes by default — the first request after idle is slow. For busy apps set it to 0 and Start Mode to AlwaysRunning.

Give the pool identity read access to the site folder:

icacls "C:\inetpub\sites\example.com" /grant "IIS AppPool\example.com:(OI)(CI)RX"
icacls "C:\inetpub\sites\example.com\uploads" /grant "IIS AppPool\example.com:(OI)(CI)M"

Write access only where the app really needs it (uploads, cache).

Step 4: Free SSL with win-acme

win-acme is a free, widely used Let’s Encrypt client for Windows that configures IIS bindings and renews certificates automatically.

  1. Download the latest release from the win-acme website and extract it to C:\Tools\win-acme.
  2. Run wacs.exe as Administrator.
  3. Choose N: Create certificate (default settings), select the site, and confirm the host names (example.com, www.example.com).

win-acme validates the domain over HTTP, installs the certificate, adds an https binding on port 443 with SNI, and creates a scheduled task to renew it before expiry. Open port 443 in the firewall if it is not already:

New-NetFirewallRule -DisplayName "HTTPS" -Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow

Check the scheduled task in Task Scheduler (“win-acme renew”).

Step 5: Redirect HTTP to HTTPS

Install the URL Rewrite module (free download from Microsoft), then add to the site’s web.config:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="HTTPS redirect" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" />
            <add input="{REQUEST_URI}" pattern="^/\.well-known/acme-challenge/" negate="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

The exception for /.well-known/acme-challenge/ keeps certificate renewals working.

Running ASP.NET Core / .NET apps

  1. Install the .NET Hosting Bundle for your .NET version on the server (it includes the ASP.NET Core Module for IIS), then restart IIS (iisreset).
  2. Publish your app (dotnet publish -c Release) and copy the output to the site folder.
  3. Set the pool to “No Managed Code”.

The app runs in-process inside IIS by default. Logs: enable stdoutLogEnabled="true" in the generated web.config temporarily when troubleshooting startup errors.

Running PHP on IIS

  1. Install the CGI feature: Install-WindowsFeature Web-CGI.
  2. Download the Non-Thread-Safe (NTS) x64 build of PHP for Windows, extract to C:\PHP, and copy php.ini-production to php.ini.
  3. In IIS Manager → Handler Mappings → Add Module Mapping: request path *.php, module FastCgiModule, executable C:\PHP\php-cgi.exe.
  4. Install the matching Visual C++ Redistributable if PHP fails to start.

WordPress and other PHP apps run, though for PHP-heavy sites Linux with Nginx is generally the more common and better-documented platform — see installing WordPress on Nginx.

Performance

  • Compression: in IIS Manager → server → Compression, enable static and dynamic compression (the Dynamic Compression feature must be installed).
  • Output caching for pages that do not change per user.
  • Static content caching: under HTTP Response Headers → Set Common Headers → Expire Web content, e.g. after 7 days, or set per folder in web.config (<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />).
  • HTTP/2 is enabled automatically for HTTPS on Windows Server 2016+; HTTP/3 is available on Windows Server 2022+ with additional configuration.

Security

  • Remove the Default Web Site or stop it, so the server IP does not show the IIS welcome page.
  • Hide version headers: URL Rewrite outbound rule to blank the Server header, and remove X-Powered-By under HTTP Response Headers.
  • Request Filtering: block access to sensitive extensions (.config, .bak, .git) and set maximum upload size.
  • Keep Windows and the .NET Hosting Bundle updated.
  • Secure Remote Desktop separately — see securing RDP.

Logs and troubleshooting

Logs are in C:\inetpub\logs\LogFiles\W3SVC<site-id>\. For errors:

Error Common cause
500.19 Invalid web.config, or a module (e.g. URL Rewrite) not installed
500.30 / 502.5 ASP.NET Core app failed to start — check stdout log, Hosting Bundle installed
401.3 Pool identity has no permission on the folder
503 Application pool stopped — check Event Viewer → Application
Wrong site shown Host name missing in bindings; DNS points elsewhere

Failed Request Tracing (Web-Http-Tracing feature) records detailed traces for specific status codes — very useful for intermittent errors.