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
- Click Start and search for "Server Manager"
- Open Server Manager
- Click "Add roles and features"
Step 2: Install IIS
- Click "Next" through the wizard
- Select "Web Server (IIS)" from the roles list
- Click "Next" and then "Install"
- Wait for installation to complete
Step 3: Verify Installation
- Open a web browser on your VPS
- Go to:
http://localhost - You should see the IIS welcome page
Setting Up Your First Website
Step 1: Create Website Files
- Open File Explorer
- Go to:
C:\inetpub\wwwroot - Create a new folder called "mywebsite"
- Create a file called
index.htmlin 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
- Open IIS Manager (search for "IIS" in Start menu)
- Right-click "Sites" in the left panel
- Select "Add Website"
- Fill in the details:
- Site name: MyWebsite
- Physical path: C:\inetpub\wwwroot\mywebsite
- Port: 80
- Click "OK"
Step 4: Test Your Website
- Open a web browser
- Go to:
http://YOUR_VPS_IP - 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)
- In IIS Manager, right-click your site
- Select "Edit Bindings"
- Click "Add"
- Set Host name to your domain (e.g.,
mywebsite.com) - 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
- In IIS Manager, select your website
- Double-click "Directory Browsing"
- Click "Enable" in the right panel
Set Default Document
- Select your website in IIS Manager
- Double-click "Default Document"
- Add your default file (e.g.,
index.html,default.aspx)
Configure Error Pages
- Select your website
- Double-click "Error Pages"
- Click "Edit Feature Settings"
- Choose error page type (Detailed or Custom)
Setting Up SSL/HTTPS
Step 1: Install SSL Certificate
- Get an SSL certificate (from Let's Encrypt or other provider)
- Open IIS Manager
- Select your website
- Double-click "SSL Settings"
- Check "Require SSL"
Step 2: Add HTTPS Binding
- Right-click your website
- Select "Edit Bindings"
- Click "Add"
- Set:
- Type: https
- Port: 443
- SSL certificate: Select your certificate
- 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
- In IIS Manager, select your website
- Double-click "Compression"
- Check "Enable dynamic content compression"
- Check "Enable static content compression"
Configure Caching
- Select your website
- Double-click "HTTP Response Headers"
- Click "Set Common Headers"
- 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
- Select your website
- Double-click "Directory Browsing"
- 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 443Monitoring and Logs
Enable Logging
- Select your website in IIS Manager
- Double-click "Logging"
- Choose log format (W3C recommended)
- Set log file location
View Logs
# Logs are usually in:
C:\inetpub\logs\LogFiles\W3SVC1\Monitor Performance
- Open Performance Monitor
- 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.