Sitecore 9.0.x installation, How I do it (Download, Install, Validate and Done)

If you are lazy enough to go through the Sitecore Installation documentation, follow this article for getting ready your Sitecore 9.0.x instance ready quickly. This installation is valid for Sitecore 9.0.1 and Sitecore 9.0.2 versions. If you want to install the latest version, Sitecore Experience Platform 9.1 Initial Release check how to install Sitecore XP 9.1.

I have divided the installation in 4 milestones, so that one can relax after achieving one.

  • Download and install all the pre requisites for Sitecore installation
  • Downloading required assets and Setting up the SOLR
  • Validating the installation process and Installing the Sitecore Platform

First things first, you need to have the pre requisites installed before installing the Sitecore. These are the pre requisites you need to have installed to setup the sitecore 9 on your machine (assuming you are using Windows 10). Here are all the things I have downloaded to initiate the process:


Step 1: Download and install all the pre requisites for Sitecore installation:

  • SQL Server:
    Sitecore works on both SQL SERVER 2014 SP2 and SQL SERVER 2016 SP1.
  • Microsoft PowerShell:
    Microsoft PowerShell version 5.0 or later, If you are installing on windows 10, It already comes with Powershell 5.1. Run this command in your PowerShell to check which version of PowerShell you are using.

    $PSversiontable
  • Visual Studio 2017:
    Visual Studio 2017 is required to work efficiently with Sitecore, Visual Studio 2015 can also work but to avoid any issues, better to use VS 2017.
    Some dependencies are required to be updated for Sitecore. e.g. MS Deploy tools , make sure you have the latest ones because it might get you in trouble at any step while running Sitecore 9 scripts.
  • Web Platform Installer:
    Web Platform Installer version 5.0 can be downloaded from Microsoft Website

Step 2: Enabling Windows Features to use IIS:

Sitecore 9 can be hosted on IIS 8.5 and IIS 10.0, preferred is to use the latest one.

Enable the following features on your windows by Turning Windows features on from Programs in Control Panel:

Turning on the windows features for IIS required for the Sitecore. I have enabled almost all of them, leaving CGI, ASP and Diagnostics. After it restart your PC as required by enabling the Windows features.


Step 3: Install Services with Web Platform Installer

Install the following services with Web platform Installer, you need to have Web Platform Installer 5.0:

  • Web Deploy 3.6 for Hosting Servers
  • URL Rewrite 2.1
  • Microsoft SQL Server Data-Tier Application Framework (DAC Fx) version 17.1
  • Microsoft SQL Server Transact-SQL ScriptDom
  • SQL System CLR Types for Microsoft  SQL Server

Step 4: Initiating the Sitecore Installation with PowerShell:

You need Microsoft PowerShell® version 5.1 or later  Following are the commands required to initiate the Sitecore Installation. Make sure you are running the PowerShell in Administrator mode:

# Enabling PowerShell Policy to allow to run commands

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

# Add the Sitecore MyGet repository to PowerShell

Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2

# Install the Sitecore Install Framwork module

Install-Module SitecoreInstallFramework

# Install the Sitecore Fundamentals module (provides additional functionality for local installations like creating self-signed certificates)

Install-Module SitecoreFundamentals

# Update Module SitecoreInstallFramework

Update-Module SitecoreInstallFramework -Force

# Trusted repo PSGallery

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

# Trusted repo SitecoreGallery

Set-PSRepository -Name SitecoreGallery -InstallationPolicy Trusted

# Import the modules into your current PowerShell context (if not already done)

Import-Module SitecoreFundamentals
Import-Module SitecoreInstallFramework

# if Sitecore.Pathfinder and Sqlsrever does not exist, install them

Install-Module Sitecore.Pathfinder
Install-Module SqlServer

# Verifying prerequisites for sitecore installation framework use these helpful commands

$PSversiontable
Get-PSRepository
Get-InstalledModule

When successfully done, you can run the above verifying command, and it will look like this, ignore the DockerMsftProvider.

2018-04-24_1827

You can run these commands in one go as well. Here is my gist link.


Step 5: Setting up the SOLR

You will require to download the followings:

  • Java SE Runtime Environment 9.0.1
  • NSSM 2.24
  • Solr 6.6.2
  1. Download all and install the JRE 9.0.1 at default location
  2. Extract all the contents of the SOLR and NSSM in the directory
    C:\solr

so the directory will look like this:

2018-04-24_1810

Now run the save the following as the PowerShell and run it, it will do the rest installation for Solr 6.6.2.

Param(
 $solrVersion = "6.6.2",
 $installFolder = "c:\solr",
 $solrPort = "8983",
 $solrHost = "solr",
 $solrSSL = $true,
 $nssmVersion = "2.24",
 $JREVersion = "9.0.1"
)

$JREPath = "C:\Program Files\Java\jre-$JREVersion" ## Note that if you're running 32bit java, you will need to change this path
$solrName = "solr-$solrVersion"
$solrRoot = "$installFolder\$solrName"
$nssmRoot = "$installFolder\nssm-$nssmVersion"
$solrPackage = "https://archive.apache.org/dist/lucene/solr/$solrVersion/$solrName.zip"
$nssmPackage = "https://nssm.cc/release/nssm-$nssmVersion.zip"
$downloadFolder = "~\Downloads"

## Verify elevated
## https://superuser.com/questions/749243/detect-if-powershell-is-running-as-administrator
$elevated = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")
if($elevated -eq $false)
{
    throw "In order to install services, please run this script elevated."
}

function downloadAndUnzipIfRequired
{
    Param(
        [string]$toolName,
        [string]$toolFolder,
        [string]$toolZip,
        [string]$toolSourceFile,
        [string]$installRoot
    )

    if(!(Test-Path -Path $toolFolder))
    {
        if(!(Test-Path -Path $toolZip))
        {
            Write-Host "Downloading $toolName..."
            Start-BitsTransfer -Source $toolSourceFile -Destination $toolZip
        }

        Write-Host "Extracting $toolName to $toolFolder..."
        Expand-Archive $toolZip -DestinationPath $installRoot
    }
}
# download & extract the solr archive to the right folder
$solrZip = "$downloadFolder\$solrName.zip"
downloadAndUnzipIfRequired "Solr" $solrRoot $solrZip $solrPackage $installFolder

# download & extract the nssm archive to the right folder
$nssmZip = "$downloadFolder\nssm-$nssmVersion.zip"
downloadAndUnzipIfRequired "NSSM" $nssmRoot $nssmZip $nssmPackage $installFolder

# Ensure Java environment variable
$jreVal = [Environment]::GetEnvironmentVariable("JAVA_HOME", [EnvironmentVariableTarget]::Machine)
if($jreVal -ne $JREPath)
{
    Write-Host "Setting JAVA_HOME environment variable"
    [Environment]::SetEnvironmentVariable("JAVA_HOME", $JREPath, [EnvironmentVariableTarget]::Machine)
}

# if we're using HTTP
if($solrSSL -eq $false)
{
    # Update solr cfg to use right host name
    if(!(Test-Path -Path "$solrRoot\bin\solr.in.cmd.old"))
    {
        Write-Host "Rewriting solr config"

        $cfg = Get-Content "$solrRoot\bin\solr.in.cmd"
        Rename-Item "$solrRoot\bin\solr.in.cmd" "$solrRoot\bin\solr.in.cmd.old"
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_HOST=192.168.1.1", "set SOLR_HOST=$solrHost" }
        $newCfg | Set-Content "$solrRoot\bin\solr.in.cmd"
    }
}

# Ensure the solr host name is in your hosts file
if($solrHost -ne "localhost")
{
    $hostFileName = "c:\\windows\system32\drivers\etc\hosts"
    $hostFile = [System.Io.File]::ReadAllText($hostFileName)
    if(!($hostFile -like "*$solrHost*"))
    {
        Write-Host "Updating host file"
        "`r`n127.0.0.1`t$solrHost" | Add-Content $hostFileName
    }
}

# if we're using HTTPS
if($solrSSL -eq $true)
{
    # Generate SSL cert
    $existingCert = Get-ChildItem Cert:\LocalMachine\Root | where FriendlyName -eq "$solrName"
    if(!($existingCert))
    {
        Write-Host "Creating & trusting an new SSL Cert for $solrHost"

        # Generate a cert
        # https://docs.microsoft.com/en-us/powershell/module/pkiclient/new-selfsignedcertificate?view=win10-ps
        $cert = New-SelfSignedCertificate -DnsName "$solrHost" -CertStoreLocation cert:\LocalMachine\My

        # Trust the cert
        # https://stackoverflow.com/questions/8815145/how-to-trust-a-certificate-in-windows-powershell
        $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "Root","LocalMachine"
        $store.Open("ReadWrite")
        $store.Add($cert)
        $store.Close()

        # remove the untrusted copy of the cert
        $cert | Remove-Item
    }

    # export the cert to pfx using solr's default password
    if(!(Test-Path -Path "$solrRoot\server\etc\solr-ssl.keystore.pfx"))
    {
        Write-Host "Exporting cert for Solr to use"

        $cert = Get-ChildItem Cert:\LocalMachine\Root | where FriendlyName -eq "$solrName"
    
        $certStore = "$solrRoot\server\etc\solr-ssl.keystore.pfx"
        $certPwd = ConvertTo-SecureString -String "secret" -Force -AsPlainText
        $cert | Export-PfxCertificate -FilePath $certStore -Password $certpwd | Out-Null
    }

    # Update solr cfg to use keystore & right host name
    if(!(Test-Path -Path "$solrRoot\bin\solr.in.cmd.old"))
    {
        Write-Host "Rewriting solr config"

        $cfg = Get-Content "$solrRoot\bin\solr.in.cmd"
        Rename-Item "$solrRoot\bin\solr.in.cmd" "$solrRoot\bin\solr.in.cmd.old"
        $newCfg = $cfg | % { $_ -replace "REM set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks", "set SOLR_SSL_KEY_STORE=$certStore" }
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_SSL_KEY_STORE_PASSWORD=secret", "set SOLR_SSL_KEY_STORE_PASSWORD=secret" }
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks", "set SOLR_SSL_TRUST_STORE=$certStore" }
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_SSL_TRUST_STORE_PASSWORD=secret", "set SOLR_SSL_TRUST_STORE_PASSWORD=secret" }
        $newCfg = $newCfg | % { $_ -replace "REM set SOLR_HOST=192.168.1.1", "set SOLR_HOST=$solrHost" }
        $newCfg | Set-Content "$solrRoot\bin\solr.in.cmd"
    }
}

# install the service & runs
$svc = Get-Service "$solrName" -ErrorAction SilentlyContinue
if(!($svc))
{
    Write-Host "Installing Solr service"
    &"$installFolder\nssm-$nssmVersion\win64\nssm.exe" install "$solrName" "$solrRoot\bin\solr.cmd" "-f" "-p $solrPort"
    $svc = Get-Service "$solrName" -ErrorAction SilentlyContinue
}
if($svc.Status -ne "Running")
{
    Write-Host "Starting Solr service"
    Start-Service "$solrName"
}

# finally prove it's all working
$protocol = "http"
if($solrSSL -eq $true)
{
    $protocol = "https"
}
Invoke-Expression "start $($protocol)://$($solrHost):$solrPort/solr/#/"

The above script is independent to downloads or JRE, SOLR and NSSM, and can also work alone, without downloading any of them. Just download it from my gist as Powershell scritpt and run it, and it will end up with this screen, easy peasy. 

2018-04-24_1821

Don’t worry if this does not show up at first. It justs takes a while depending on your hardware. If your script executed successfully, it will show up.

Here is my complete script for installing the SOLR for Sitecore. Follow this in case of updates. Thanks to @jermdavis for his gist.


Step 6: Initiating the Sitecore Install

You should see the following when extract the Sitecore 9.0.1 rev. 171219 (WDP XP0 packages).zip to your working directory, for me it is:

D:\SC9i
  • Sitecore 9.0.1 rev. 171219 (OnPrem)_single.scwdp.zip
  • Sitecore 9.0.1 rev. 171219 (OnPrem)_zp0xconnect.scwdp.zip
  • XP0 Configuration Files 9.0.1 rev 171219.zip

Further extract XP0 Configuration Files 9.0.1 rev 171219.zip at the same path, so you find the files this way:


Step 7: Validating the pre-requisites for the Sitecore Installation with SifLess

I use GUI for SIF called SIFless written by Rob Ahnemann.

Download the SIFLess and extract it in the same directory, and run SIFLess.exe

D:\SC9i\sifless

Fill all the respective fields as configured on your machine (everything is in the same folder, so don’t worry),  Click on Test It will look like this:

2018-04-24_1833.png

Once Validated, you click Generate Files button.

Step 8: Run the Sitecore Installation script generated with SifLess

Now open PowerShell and change the directory to:

D:\SC9i\sifless

2018-04-24_1856

Find the new generated files as `SIFLess-EZ-**********.ps1` and Run.

This will take around 10 minutes, Don’t worry if it stops. Wait for the script to complete. You might face warnings, but don’t worry about it.

Screenshot (44)

And it is Done.

2018-04-28_0239

If your installation is not complete, you might face issues Sitecore xConnect Search Indexer and Sitecore Marketing Automation Engine. Make sure to stop them properly, before trying for another round.

Once done with the installation, make sure to rebuild the indexes for all the databases in the website, and do the IIS reset.


UPDATE:

For Sitecore 9 Update 2 Installation, Just Update the packages paths for Package, XConnect and configs using SIFless.

2018-07-01_2041.png

Populating Schemas took more time than expected, but worked!

2018-07-01_2001 - Copy

2018-07-01_2016_001



Feel free to share your issues you face with me. And what do you think about my way of Sitecore 9 installation.

Cheers!

Reference Links:

Advertisements

Share what's in your Mind :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.