I needed to configure Host Named Site Collections for a few customers and ran into a few problems especially with the creation of MySites. I know that Host Named Site Collections (HNSC) were available in SharePoint 2010 and that Microsoft improved it in SharePoint 2013. Didn’t play with it in SharePoint 2010 and now with SharePoint 2013 I needed to configure it in order for customers to use the SharePoint app store.
Microsoft is recommending the HNSC as a preferred method as stated on TechNet: “Host-named site collections are the preferred method to deploy sites in SharePoint 2013“. However there are some things that doesn’t work out-of-the-box. As you may now the creation of HNSC can only be done by using PowerShell. There is no option within the GUI!
Host Named Site Collection creation
The creation as described on TechNet:
- Create a web application for host-named site collections
New-SPWebApplication -Name ‘Contoso Sites’ -port 80 -ApplicationPool ContosoAppPool -ApplicationPoolAccount (Get-SPManagedAccount ‘Contoso\JDoe’) -AuthenticationProvider (New-SPAuthenticationProvider –UseWindowsIntegratedAuthentication)
- Create a root site collection
New-SPSite ‘http://<servername>’ -Name ‘Portal’ -Description ‘Portal on root’ -OwnerAlias ‘contoso\administrator’ -language 1033 -Template ‘STS#0’
- Create host-named site collections
New-SPSite ‘http://portal.contoso.com’ -HostHeaderWebApplication ‘http://<servername>’ -Name ‘Portal’ -Description ‘Customer root’ -OwnerAlias ‘contoso\administrator’ -language 1033 -Template ‘STS#0’
It’s also possible to use managed paths with host-named site collections, first you have to create a managed path and then the host-named site collection:
New-SPManagedPath ‘departments’ –HostHeader
New-SPSite ‘http://portal.contoso.com/departments/marketing’ -HostHeaderWebApplication ‘http://<servername>’ -Name ‘Marketing’ -Description ‘Portal Marketing’ -OwnerAlias ‘contoso\administrator’ -language 1033 -Template ‘STS#0’
Personal Site creation
On the TechNet page (see Resources), it’s not mentioned how you setup MySites with Host Named Site Collections. They only mention that it’s possible to have MySites as Host Named Site Collections and that the Self Service Site Creation does not work. So how do we configure MySites as Host Named Site Collections?
- Create a MySite database
New-SPContentDatabase WSS_Content_MySite -WebApplication “http://<servername>”
- Create a host-named site collection
New-SPSite ‘http://mysite.contoso.com’ -OwnerAlias ‘contoso\username’ -HostHeaderWebApplication ‘http://<servername>’ -Name “MySite Host” –Template “SPSMSITEHOST#0” -Language 1033 -ContentDatabase WSS_Content_MySite
- Create a managed Path
New-SPManagedPath “personal” –HostHeader
After running the commands you will be able to browse to the mysite Host, but creating your personal part of the mysite can’t be executed. This can be resolved by turning on Self Service Site Creation for the web application, make sure that this will be hidden for your users.
Next thing I needed to do was to create an additional Managed Path for the web application:
New-SPManagedPath “personal” -WebApplication “http://<servername”
This will actually lead to be able to create the personal part of the mysite. J
There is one catch however, you’re not be able to control in which content database the mysites will be created. There are two options to this problem, lock all databases except the mysite database(s) or use code. The first option, locking databases can be done, but is tricky. If you need to create an additional site collection in a locked database, you need to unlock that database in order to create the site collection. It is possible that there will be a mysite created that same time and stored in your unlocked database.
Give your favorite developer a cup of coffee and ask him to write some code that will handle the creation of the mysites. I’m not a developer, but I ran into a blog post from Wictor Wilen where Wictor provides the code for handling the creation of mysites into the correct mysite database(s). See Resources.
If you executed all the commands and mysite creation fails, check if there is something going on with the User Profile Service. In my case it turned out that the User Profile Import was in a stopping state. Also check if the FIM services are started.