Windows Servers

How to Install and Configure IIS on Windows Server

By NileVPS Team · Published · 5 min read

اقرأ المقال بالعربي

Internet Information Services (IIS) is the web server built into Windows Server. It hosts classic ASP.NET and ASP.NET Core applications, static sites, PHP through FastCGI, and acts as a reverse proxy when you add the right modules. If your application stack is Microsoft-centric, IIS on a Windows VPS is usually the most natural home for it. This guide walks through installing IIS, creating your first site, adding HTTPS and applying sensible security defaults.

Before you start

Make sure you have:

  • A Windows Server 2019 or 2022 machine with administrator access over RDP or the browser console.
  • The latest Windows updates installed.
  • A domain name pointing to the server's public IP if you plan to use HTTPS.
  • Ports 80 and 443 allowed in any cloud firewall in front of the server, not just in Windows Firewall.

If you do not have a server yet, you can deploy a Windows VPS and follow along on a clean installation.

Installing IIS

Option 1: Server Manager

  1. Open Server Manager and choose Manage > Add Roles and Features.
  2. Select Role-based or feature-based installation and pick your server.
  3. Tick Web Server (IIS) and accept the management tools it proposes.
  4. On the Role Services page, add what your application needs, for example ASP.NET 4.8, CGI (for PHP), HTTP Redirection or Request Filtering.
  5. Click Install and wait for it to finish. A reboot is normally not required.

Option 2: PowerShell

PowerShell is faster and repeatable. Run an elevated session:

# Core web server plus the IIS Manager console
Install-WindowsFeature -Name Web-Server -IncludeManagementTools

# Common extras: ASP.NET 4.x, CGI for PHP, HTTP redirection
Install-WindowsFeature -Name Web-Asp-Net45, Web-CGI, Web-Http-Redirect

To check what is installed:

Get-WindowsFeature -Name Web-* | Where-Object Installed

Open http://localhost on the server. The default IIS welcome page confirms the service is running. Its files live in C:\inetpub\wwwroot.

Creating a website

It is good practice to give each site its own folder and its own application pool, so a crash or memory leak in one site does not affect others.

Import-Module WebAdministration

New-Item -ItemType Directory -Path C:\sites\example
New-WebAppPool -Name "example"
New-Website -Name "example" -PhysicalPath "C:\sites\example" `
  -HostHeader "example.com" -Port 80 -ApplicationPool "example"

The application pool runs under the virtual account IIS AppPool\example. Grant it read access to the site folder, and write access only to folders that really need it, such as an uploads directory:

icacls C:\sites\example /grant "IIS AppPool\example:(OI)(CI)RX"

If you no longer need the default site, stop it so it does not answer requests for unknown host names:

Stop-Website -Name "Default Web Site"

Application pool settings worth knowing

SettingWhat it doesTypical choice
.NET CLR versionRuntime for classic ASP.NETv4.0 for ASP.NET 4.x, No Managed Code for ASP.NET Core and PHP
IdentityAccount the worker process runs asApplicationPoolIdentity
Start modeWhether the pool starts on demandAlwaysRunning for apps with slow startup
Idle time-outStops the worker after inactivity0 (disabled) for busy production sites
Regular time intervalScheduled recycleSet a fixed off-peak time instead of the default interval

Hosting ASP.NET Core and PHP

ASP.NET Core needs the ASP.NET Core Hosting Bundle from Microsoft, which installs the runtime and the ASP.NET Core Module for IIS. Install it after IIS, then run iisreset. Publish your app to the site folder and set the pool to No Managed Code.

PHP runs through FastCGI. Install the CGI role service, download a Non-Thread-Safe PHP build for Windows, extract it (for example to C:\php), then add a handler mapping for *.php that points to C:\php\php-cgi.exe using the FastCgiModule. Add index.php to the site's default documents.

Adding HTTPS

You need a certificate in the Windows certificate store and an HTTPS binding. For free certificates, the open-source win-acme client requests Let's Encrypt certificates, creates the binding and schedules renewals automatically. After running it, verify the binding:

Get-WebBinding -Name "example"

For multiple sites on one IP address, enable Server Name Indication (SNI) on each HTTPS binding. To force HTTPS, install Microsoft's URL Rewrite module and add a redirect rule, or use HTTP Redirection on the port 80 binding of a separate site.

Security checklist for IIS

  • Install only the role services you use. Each extra module is more attack surface.
  • Keep Directory Browsing disabled unless a folder must be listed.
  • Use Request Filtering to block dangerous file extensions and limit request sizes.
  • Remove the X-Powered-By header under HTTP Response Headers.
  • Run every site in its own pool with ApplicationPoolIdentity, never as an administrator.
  • Restrict RDP to your own IP addresses in the cloud firewall while keeping 80 and 443 public.
  • Review logs in C:\inetpub\logs\LogFiles and keep Windows Update current.

For a broader hardening plan, see our guide to Windows Server security best practices.

Useful commands

iisreset                       # restart all IIS services
Get-Website                    # list sites and their state
Restart-WebAppPool -Name example
Get-IISAppPool                 # requires the IISAdministration module

FAQ

Do I need a separate license for IIS?

No. IIS is a role included with Windows Server, so there is no extra license for the web server itself. You only need a valid Windows Server license for the machine.

Why does my site work on the server but not from the internet?

The most common causes are a cloud firewall that blocks ports 80 or 443, a DNS record that points to a different IP, or a binding whose host name does not match the domain you are typing. Check each one in that order.

Can IIS act as a reverse proxy for Node.js or other backends?

Yes. Install the URL Rewrite and Application Request Routing (ARR) modules, enable the proxy in ARR's server settings, then create rewrite rules that forward requests to the backend port.

Related guides