Skip to main content

Install IIS (Web Server)

This guide explains how to install and configure IIS (Internet Information Services) on your Windows VPS.

What is IIS?​

IIS is Microsoft's web server, built into Windows Server. It allows you to host websites, ASP.NET applications, PHP, and more.

Installing IIS​

# Install IIS with basic features
Install-WindowsFeature -Name Web-Server -IncludeManagementTools

# Install with all common features
Install-WindowsFeature -Name Web-Server, Web-Common-Http, Web-Static-Content, Web-Default-Doc, Web-Dir-Browsing, Web-Http-Errors, Web-Http-Logging, Web-Stat-Compression, Web-Filtering, Web-Mgmt-Console -IncludeManagementTools

Via GUI​

  1. Open Server Manager
  2. Click Manage > Add Roles and Features
  3. Next until Server Roles
  4. Check Web Server (IIS)
  5. Add required features
  6. Next and Install

Verify Installation​

  1. Open a browser on the VPS
  2. Go to http://localhost
  3. You should see the IIS welcome page

From outside, access http://YOUR_IP

IIS Manager​

Open IIS Manager:

  • Win + R > inetmgr

Or search for "Internet Information Services (IIS) Manager"

Create a Website​

Via IIS Manager​

  1. In the left panel, right-click Sites
  2. Click Add Website...
  3. Configure:
    • Site name: MySite
    • Physical path: C:\inetpub\wwwroot\mysite
    • Binding:
      • Type: http
      • Port: 80
      • Host name: mysite.example.com (optional)
  4. Click OK

Via PowerShell​

# Create the folder
New-Item -Path "C:\inetpub\wwwroot\mysite" -ItemType Directory

# Create the site
New-IISSite -Name "MySite" -PhysicalPath "C:\inetpub\wwwroot\mysite" -BindingInformation "*:80:mysite.example.com"

File Structure​

Place your files in the site folder:

C:\inetpub\wwwroot\mysite\
β”œβ”€β”€ index.html
β”œβ”€β”€ css\
β”œβ”€β”€ js\
└── images\

Configure Multiple Sites​

# Site 1
New-IISSite -Name "Site1" -PhysicalPath "C:\inetpub\wwwroot\site1" -BindingInformation "*:80:site1.example.com"

# Site 2
New-IISSite -Name "Site2" -PhysicalPath "C:\inetpub\wwwroot\site2" -BindingInformation "*:80:site2.example.com"

Method 2: By Different Port​

# Site on port 8080
New-IISSite -Name "Site2" -PhysicalPath "C:\inetpub\wwwroot\site2" -BindingInformation "*:8080:"

Install PHP​

Download PHP​

  1. Download PHP from windows.php.net
  2. Choose the Non Thread Safe (NTS) x64 version
  3. Extract to C:\php

Configure PHP​

# Rename the configuration file
Copy-Item "C:\php\php.ini-production" "C:\php\php.ini"

Edit C:\php\php.ini:

extension_dir = "C:\php\ext"
cgi.fix_pathinfo=0

; Enable common extensions
extension=curl
extension=gd
extension=mbstring
extension=mysqli
extension=openssl
extension=pdo_mysql

Install CGI for IIS​

Install-WindowsFeature -Name Web-CGI

Configure PHP Handler​

  1. Open IIS Manager
  2. Select your server
  3. Double-click Handler Mappings
  4. Click Add Module Mapping...
    • Request path: *.php
    • Module: FastCgiModule
    • Executable: C:\php\php-cgi.exe
    • Name: PHP
  5. Click OK

Test PHP​

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

<?php
phpinfo();
?>

Access http://YOUR_IP/info.php

Security

Delete info.php after testing!

Configure HTTPS with SSL​

Generate a Self-Signed Certificate (testing)​

New-SelfSignedCertificate -DnsName "mysite.example.com" -CertStoreLocation "cert:\LocalMachine\My"

Add HTTPS Binding​

  1. IIS Manager > Sites > Your site
  2. Right-click > Edit Bindings...
  3. Add...
    • Type: https
    • Port: 443
    • SSL certificate: Select your certificate
  4. OK

With Let's Encrypt (production)​

Use win-acme:

# Download and extract win-acme
# Then run
.\wacs.exe

Follow the instructions to generate a free certificate.

Useful IIS Commands​

# Start/Stop IIS
iisreset /start
iisreset /stop
iisreset /restart

# Start/Stop a site
Start-IISSite -Name "MySite"
Stop-IISSite -Name "MySite"

# List sites
Get-IISSite

# Delete a site
Remove-IISSite -Name "MySite" -Confirm:$false

IIS Logs​

Logs are located in:

C:\inetpub\logs\LogFiles\W3SVC[SITE_ID]\

To change the location:

  1. IIS Manager > Your site
  2. Double-click Logging
  3. Modify the Directory

Application Pools​

Each site uses an application pool to isolate processes.

# Create a pool
New-WebAppPool -Name "MyPool"

# Assign to a site
Set-ItemProperty "IIS:\Sites\MySite" -Name applicationPool -Value "MyPool"

# Recycle a pool (clean restart)
Restart-WebAppPool -Name "MyPool"

Troubleshooting​

500 Error Page​

  • Check logs in C:\inetpub\logs\LogFiles\
  • Enable detailed errors:
Set-WebConfigurationProperty -Filter "system.webServer/httpErrors" -Name "errorMode" -Value "Detailed"

Permissions​

# Grant permissions to the application pool
icacls "C:\inetpub\wwwroot\mysite" /grant "IIS AppPool\MyPool:(OI)(CI)F"
Tip

For .NET applications, use the application pool with the appropriate CLR version (.NET CLR v4.0).