This article explains how to provision an IIS frontend server with full WebMatrix compatibility in an automated manner. It fully automates all steps described in the rest of this documentation, with one exception: a Microsoft SQL Server or MySQL Server is expected to be provisioned separately and is not covered here.
- Windows Server 2008 R2
- Powershell v1 enabled on the above server
- Internet connectivity on the above server (to download software requirements)
Preparing to Run Scripts
- Download the scripts from this location:
- Extract them to %systemdrive%\Webmatrix
- Launch a Powershell console in Administrator mode
- Run this command: Set-Executionpolicy Unrestricted - force. This will allow the unsigned scripts to execute.
Installing Software Requirements
The script pack contains a program called webpicmdline.exe in the \webpicmdline folder.
- Open an elevated command prompt (cmd.exe, NOT Powershell)
- Run this command to install the software stack:
Configuring the Web Management Service
Run .\01_InitializeWebManagementService.ps1. This script will do the following:
- Set service startup type to Automatic
- Enable remote connections
- Enable tracing
- Increase number of tracing logs files that are retained
- Restart Web Management Service
Creating Web Deploy Delegation Rules
The script .\02_AddDelegationRules.ps1 creates Web Deploy delegation rules. This script will create the following delegation rules:
The script needs several parameter inputs for the rules to be created properly:
- elevatedUsername: username of a user who has Write access to applicationHost.config. Required for createApp, appPoolNetFx, appPoolPipeline rules.
- elevatedPassword: password of above user
- adminUsername: username of a user who is in the Administrators group on the IIS server. Required for recyleApp rule.
- adminPassword: password of above user.
Please note that the script CREATES these above users.
.\02_AddDelegationRules.ps1 -elevatedUsername wdeploy_elevated -elevatedPassword <password> -adminUsername wdeploy_admin -adminPassword <password>
Installing the Extensionless URL hotfix
This will download and install the hotfix, KBKB980368.
NOTE: We suppress server reboots during the hotfix installation. You may need to restart the server (shutdown /r) after the update installs.
Virtual Dedicated: Creating and Assigning a New Self-signed Certificate
The Web Management Service is installed by default with a self-signed certificate. If you run sysprep after installing IIS (as is common with virtual dedicated servers), the self-signed certificate is no longer valid as the machine SID has changed, and you may see errors when connecting to the Web Management Service. You need to create a new self-signed certificate and assign it to the Web Management Service.
Run .\00_Certificate.ps1. This script will:
- Remove the SSL binding of the old certificate on port 8172
- Create a new self-signed certificate
- Bind new self-signed certificate to port 8172
- Configure Web Management Service to use new self-signed certificate
- Restart Web Management Service
This script needs to run on the first logon into the image. If you do this as the very last step before running sysprep, it ensures the certificate script runs on the next login.
- Start regedit.exe
- Navigate to HKCU\Software\Microsoft\Windows\CurrentVersion
- Create a key called RunOnce if it doesn’t already exist
- Right-click the RunOnce key add a new String value. Name the value anything (e.g. – “CertInitScript”)
- Double click the string value and add the following for its data:
Note: You can easily modify this script to assign an existing certificate (such as a trusted root certificate) to the Web Management Service. This is recommended so WebMatrix users do not see a certificate warning when publishing to your server.
- 02_AddDelegationRules.ps1 does not work with shared configuration. Workaround: change the GetApplicationHostConfigPath function in HostingCommon.psm1 to return the path to your shared configuration.
Scripts create a log file in the same folder they are run, starting with HostingLog.
Discuss in IIS Forums