How to prepare a Windows Server 2012 for web deployment

Here is a list of steps for preparation of a Windows Server 2012 for deployment of web packages or deployment from Visual Studio.

windows-server

  1. Activate Web server role
  2. Install Web Deploy
  3. Open network ports
  4. Create an account for deployment
  5. Create web sites
  6. Configure deployment for sites

1. Activate Web server role

webserverrole

Enable Management Service feature
managementservice

2. Install Web Deploy

The easiest way to install Web Deploy is using Web Platform Installer. Web Platform Installer must be downloaded and installed separately and after installation Web Platform Installer icon is available in the Management section of IIS management console.

webplatforminstaller

Search for “deploy” in the list of available packages and select Web Deploy and Web Deploy Hosting Service for installation.

webdeploypackages

Check that Web Deployment Agent Service and Web Management Service are running after the Web Deploy installation.

deployservices

Wed Deploy creates to users in Administrators group: WDeployAdmin and WDeployConfigWriter. Set “Password never expires” on both accounts

wdeployadmin

3. Network ports

Two TCP ports must be opened to our windows server: 80 and 8172. By default, the Web Deployment Agent Service (MsDepSvc) listens on port 80, and the Web Management Service (WmSvc) listens on port 8172 by default.

To check server availability on these ports open the following links in a web browser:
http://<ip-address>/MSDeployAgentService
https://<ip-address>:8172/msdeploy.axd

We will be asked for login and password. We can login using server Administrator account. In case of connection to 8172 port we will be asked about invalid security self-signed certificate.

5. Create an account for deployment

We can either use Administrator account for deployment or create a new account. I could not make deployment work with IIS Manager accounts. In my case only Windows users included in Administrators group was able to deploy applications to web server through command line.

Lets create a new user called deploy. This user should not be able to change password and password should never expires.

deployaccount

6. Create web sites

An application can be deployed either to a web site or to a web application. There is one site called “Default Web Site” that is available by default.

sitesandapplications

If we want to deploy an application to other site then default it must be created before hand.

addwebsite

7. Configure deployment for sites

Every site that will accept deploy must be configured for this. Select “Deploy” in site’s context menu and choose “Configure Web Deploy Publishing…”

deploycontextmenu

Choose a user account to perform deploy.

configurewebdeploy

8. Test deployment from Visual Studio

Create a new publishing profile. And write exactly! the same Server name and site name in profile settings:

publishvs

Verify Connection and accept the certificate.

validateconnection

Then just Publish and application will be immediately published using the just created publishing profile.

Here is an official guide Installing and Configuring Web Deploy on IIS 8.0 or Later.