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
Via PowerShell (recommended)
# 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
- Open Server Manager
- Click Manage > Add Roles and Features
- Next until Server Roles
- Check Web Server (IIS)
- Add required features
- Next and Install
Verify Installation
- Open a browser on the VPS
- Go to
http://localhost - 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
- In the left panel, right-click Sites
- Click Add Website...
- Configure:
- Site name: MySite
- Physical path:
C:\inetpub\wwwroot\mysite - Binding:
- Type: http
- Port: 80
- Host name: mysite.example.com (optional)
- 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
Method 1: By Domain Name (recommended)
# 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
- Download PHP from windows.php.net
- Choose the Non Thread Safe (NTS) x64 version
- 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
- Open IIS Manager
- Select your server
- Double-click Handler Mappings
- Click Add Module Mapping...
- Request path:
*.php - Module:
FastCgiModule - Executable:
C:\php\php-cgi.exe - Name:
PHP
- Request path:
- Click OK
Test PHP
Create C:\inetpub\wwwroot\info.php:
<?php
phpinfo();
?>
Access http://YOUR_IP/info.php
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
- IIS Manager > Sites > Your site
- Right-click > Edit Bindings...
- Add...
- Type: https
- Port: 443
- SSL certificate: Select your certificate
- 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:
- IIS Manager > Your site
- Double-click Logging
- 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"
For .NET applications, use the application pool with the appropriate CLR version (.NET CLR v4.0).