LogoAirnode Hosting
Windows VPS

How to Set Up IIS Web Server on Your Windows VPS

What is IIS?

IIS (Internet Information Services) is Microsoft's web server. It's perfect for hosting websites, especially ASP.NET applications.

IIS is the web server that comes with Windows Server. It's great for hosting websites, especially if you're using Microsoft technologies like ASP.NET.


Why Choose IIS?

  • Built into Windows - No extra installation needed
  • Great for ASP.NET - Perfect for Microsoft web applications
  • Easy to manage - User-friendly interface
  • Good security - Built-in security features
  • Windows integration - Works great with other Windows services
  • Professional support - Microsoft-backed solution

Resource Usage

IIS uses more resources than Nginx or Apache, so make sure your VPS has enough RAM and CPU.


Installing IIS

Step 1: Open Server Manager

  1. Click Start and search for "Server Manager"
  2. Open Server Manager
  3. Click "Add roles and features"

Step 2: Install IIS

  1. Click "Next" through the wizard
  2. Select "Web Server (IIS)" from the roles list
  3. Click "Next" and then "Install"
  4. Wait for installation to complete

Step 3: Verify Installation

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

Setting Up Your First Website

Step 1: Create Website Files

  1. Open File Explorer
  2. Go to: C:\inetpub\wwwroot
  3. Create a new folder called "mywebsite"
  4. Create a file called index.html in the folder

Step 2: Add Content to Your Website

Open index.html in Notepad and add:

<!DOCTYPE html>
<html>
<head>
    <title>My Website</title>
</head>
<body>
    <h1>Welcome to My Website!</h1>
    <p>This is my first website on IIS.</p>
</body>
</html>

Step 3: Create IIS Site

  1. Open IIS Manager (search for "IIS" in Start menu)
  2. Right-click "Sites" in the left panel
  3. Select "Add Website"
  4. Fill in the details:
    • Site name: MyWebsite
    • Physical path: C:\inetpub\wwwroot\mywebsite
    • Port: 80
  5. Click "OK"

Step 4: Test Your Website

  1. Open a web browser
  2. Go to: http://YOUR_VPS_IP
  3. You should see your website

Setting Up Multiple Websites

Method 1: Different Ports

# Create website on port 8080
New-Website -Name "Website2" -Port 8080 -PhysicalPath "C:\inetpub\wwwroot\website2"

# Create website on port 8081
New-Website -Name "Website3" -Port 8081 -PhysicalPath "C:\inetpub\wwwroot\website3"

Method 2: Host Headers (Different Domains)

  1. In IIS Manager, right-click your site
  2. Select "Edit Bindings"
  3. Click "Add"
  4. Set Host name to your domain (e.g., mywebsite.com)
  5. Click "OK"

Method 3: Different Folders

# Create websites in different folders
New-Website -Name "Blog" -Port 80 -PhysicalPath "C:\websites\blog"
New-Website -Name "Store" -Port 80 -PhysicalPath "C:\websites\store"

Configuring IIS Settings

Enable Directory Browsing

  1. In IIS Manager, select your website
  2. Double-click "Directory Browsing"
  3. Click "Enable" in the right panel

Set Default Document

  1. Select your website in IIS Manager
  2. Double-click "Default Document"
  3. Add your default file (e.g., index.html, default.aspx)

Configure Error Pages

  1. Select your website
  2. Double-click "Error Pages"
  3. Click "Edit Feature Settings"
  4. Choose error page type (Detailed or Custom)

Setting Up SSL/HTTPS

Step 1: Install SSL Certificate

  1. Get an SSL certificate (from Let's Encrypt or other provider)
  2. Open IIS Manager
  3. Select your website
  4. Double-click "SSL Settings"
  5. Check "Require SSL"

Step 2: Add HTTPS Binding

  1. Right-click your website
  2. Select "Edit Bindings"
  3. Click "Add"
  4. Set:
    • Type: https
    • Port: 443
    • SSL certificate: Select your certificate
  5. Click "OK"

Step 3: Redirect HTTP to HTTPS

<!-- Add to web.config file -->
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="HTTP to HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Performance Optimization

Enable Compression

  1. In IIS Manager, select your website
  2. Double-click "Compression"
  3. Check "Enable dynamic content compression"
  4. Check "Enable static content compression"

Configure Caching

  1. Select your website
  2. Double-click "HTTP Response Headers"
  3. Click "Set Common Headers"
  4. Set cache control for static files

Enable Gzip Compression

<!-- Add to web.config -->
<configuration>
  <system.webServer>
    <httpCompression>
      <dynamicTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
      </dynamicTypes>
    </httpCompression>
  </system.webServer>
</configuration>

Security Settings

Disable Directory Browsing

  1. Select your website
  2. Double-click "Directory Browsing"
  3. Click "Disable"

Hide Server Information

<!-- Add to web.config -->
<configuration>
  <system.webServer>
    <security>
      <requestFiltering removeServerHeader="true" />
    </security>
  </system.webServer>
</configuration>

Set File Permissions

# Set proper permissions for website folder
icacls "C:\inetpub\wwwroot\mywebsite" /grant "IIS_IUSRS:(OI)(CI)(RX)"
icacls "C:\inetpub\wwwroot\mywebsite" /grant "IUSR:(OI)(CI)(RX)"

Troubleshooting Common Problems

Problem: "403 Forbidden"

Solutions:

  • Check file permissions
  • Verify the website folder exists
  • Make sure IIS_IUSRS has access

Problem: "404 Not Found"

Solutions:

  • Check if the file exists
  • Verify the default document is set
  • Check the physical path in IIS

Problem: "500 Internal Server Error"

Solutions:

  • Check the application logs
  • Verify .NET Framework is installed
  • Check web.config for errors

Problem: "Cannot start website"

Solutions:

  • Check if port is already in use
  • Verify the application pool is running
  • Check Windows Firewall settings

Useful PowerShell Commands

# List all websites
Get-Website

# Start a website
Start-Website -Name "MyWebsite"

# Stop a website
Stop-Website -Name "MyWebsite"

# Create a new website
New-Website -Name "NewSite" -Port 80 -PhysicalPath "C:\websites\newsite"

# Remove a website
Remove-Website -Name "OldSite"

# Get website bindings
Get-WebBinding -Name "MyWebsite"

# Add binding
New-WebBinding -Name "MyWebsite" -Protocol "https" -Port 443

Monitoring and Logs

Enable Logging

  1. Select your website in IIS Manager
  2. Double-click "Logging"
  3. Choose log format (W3C recommended)
  4. Set log file location

View Logs

# Logs are usually in:
C:\inetpub\logs\LogFiles\W3SVC1\

Monitor Performance

  1. Open Performance Monitor
  2. Add counters for:
    • Web Service
    • ASP.NET Applications
    • Memory and CPU

Best Practices

1. Regular Updates

  • Keep Windows updated
  • Update IIS regularly
  • Patch security vulnerabilities

2. Backup Configuration

# Export IIS configuration
%windir%\system32\inetsrv\appcmd.exe add backup "MyBackup"

3. Monitor Resources

  • Check disk space regularly
  • Monitor memory usage
  • Watch for high CPU usage

4. Security

  • Use HTTPS for all websites
  • Keep permissions minimal
  • Regular security audits

Your Web Server is Ready!

IIS is now running and serving your websites! Remember to keep it updated and monitor performance regularly.

On this page