Sitecore 9 On Premises installation step by step using SIF
Introduction
In this blog I will be talking about Sitecore 9 XP Single (XP0) On Premises installation step by step using SIF (Sitecore Install Framework).
SIF
The Sitecore Installation Framework is a Microsoft® Powershell module that supports local and remote installations of Sitecore, and it is fully extensible. You can install the entire Sitecore solution (XP), or the CMS-only mode (XM) solution.
Prerequisites
- Web Deploy 3.6 for Hosting Servers.
- URL Rewrite 2.1 (Use Web Platform Installer to install).
· We need to have Java runtime installed
- Go to advanced system settings by writing ‘advanced’in windows search.
- Click ‘Environment Variables’button and add ‘JAVA_HOME’to the system variable as you can see below:
- Scroll down in System variables area and select path then click edit.
- A new window will appear, click new and enter ‘%JAVA_HOME%\bin’ as you can see below:
- Click ‘OK’ for all opened windows.
- To make sure that Java installed correctly, open cmd and write the below:
java –version
Installation with Microsoft PowerShell®
SIF is available using through Sitecore Gallery, to install MyGet repository, in Windows, launch Microsoft PowerShell® as an administrator and run the following cmdlet:
Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2
- Enter ‘Y’ and click enter.
- Install the PowerShell module by running the following cmdlet:
Install-Module SitecoreInstallFramework
- Enter ‘Y’ and click enter.
- Install the Sitecore Fundamentals module by running the following cmdlet:
Install-Module SitecoreFundamentals
- Import the modules into your current PowerShell context by running the following cmdlet:
Import-Module SitecoreFundamentals
Import-Module SitecoreInstallFramework
Install Solr
- We need to install Solr 6.6.2, to download this click here. Make sure to extract the .zip file on the following path:
C:\solr-6.6.2
Enabling SSL
1. Generate a Self-Signed Certificate and a Key
- Create new folder under Solr path "C:\solr-6.6.2\bin\etc" called ‘etc’.
- To generate a self-signed certificate and a single key, open windows command prompt (cmd) as an administrator and go to etc folder you just created (Write > cd C:\solr-6.6.2\bin\etc ) and run the below commands:
keytool -genkeypair -alias solr-ssl -keyalg RSA -keysize 2048 -keypass 123456 -storepass 123456 -validity 9999 -keystore solr-ssl.keystore.jks -ext SAN=DNS:localhost,IP:127.0.0.1 -dname "CN=localhost, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country"
2. Convert the Certificate and Key to PEM Format for Use with cURL
- First convert the JKS keystore into PKCS12 format using keytool (in cmd):
keytool -importkeystore -srckeystore solr-ssl.keystore.jks -destkeystore solr-ssl.keystore.p12 -srcstoretype jks -deststoretype pkcs12
12
- cmd will ask you to enter passwords, please enter 123456 as we used this in generating self-signed certificate above.
- Next convert the PKCS12 format keystore, including both the certificate and the key, into PEM format using the OpenSSL command (in cmd):
C:\OpenSSL-Win64\bin\openssl pkcs12 -in solr-ssl.keystore.p12 -out solr-ssl.pem
- Close cmd and go to the below path to installed the certificate by selecting ‘solr-ssl.keystore.p12’ and right click and choose install.
3. Set Common SSL-Related System Properties
- To activate the SSL settings, open this file ‘C:\solr-6.6.2\bin\solr.in.cmd’and uncomment and update the set of properties beginning with SOLR_SSL as you can see below:
- Now we need to run Solr as a Windows service, to do so we need do the following:
2. Open command prompt as an administrator and go to the above folder, enter (> cd C:\nssm-2.24\win64).
3. Install Solr by writing (nssm install solr-6.2.2) in cmd.
4. The below window will appear:
5. Select the path and the startup directory for Solr as you see in the above screenshot and click install service button.
6. Go to windows services and start Solr service
4. Run Single Node Solr using SSL
1. Save the below Powershell script in a file (ex: C:\Sitecore\Sitecore 9\ Solr-SSL.ps1).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string]$KeystoreFile = 'solr-ssl.keystore.jks', | |
[string]$KeystorePassword = '123456', | |
[string]$SolrDomain = 'localhost', | |
[switch]$Clobber | |
) | |
$ErrorActionPreference = 'Stop' | |
### PARAM VALIDATION | |
if($KeystorePassword -ne '123456') { | |
Write-Error 'The keystore password must be "secret", because Solr apparently ignores the parameter' | |
} | |
if((Test-Path $KeystoreFile)) { | |
if($Clobber) { | |
Write-Host "Removing $KeystoreFile..." | |
Remove-Item $KeystoreFile | |
} else { | |
$KeystorePath = Resolve-Path $KeystoreFile | |
Write-Error "Keystore file $KeystorePath already existed. To regenerate it, pass -Clobber." | |
} | |
} | |
$P12Path = [IO.Path]::ChangeExtension($KeystoreFile, 'p12') | |
if((Test-Path $P12Path)) { | |
if($Clobber) { | |
Write-Host "Removing $P12Path..." | |
Remove-Item $P12Path | |
} else { | |
$P12Path = Resolve-Path $P12Path | |
Write-Error "Keystore file $P12Path already existed. To regenerate it, pass -Clobber." | |
} | |
} | |
try { | |
$keytool = (Get-Command 'C:\Program Files\Java\jre1.8.0_171\bin\keytool.exe').Source | |
} catch { | |
$keytool = Read-Host "keytool.exe not on path. Enter path to keytool (found in JRE bin folder)" | |
if([string]::IsNullOrEmpty($keytool) -or -not (Test-Path $keytool)) { | |
Write-Error "Keytool path was invalid." | |
} | |
} | |
### DOING STUFF | |
Write-Host '' | |
Write-Host 'Generating JKS keystore...' | |
& $keytool -genkeypair -alias solr-ssl -keyalg RSA -keysize 2048 -keypass $KeystorePassword -storepass $KeystorePassword -validity 9999 -keystore $KeystoreFile -ext SAN=DNS:$SolrDomain,IP:127.0.0.1 -dname "CN=$SolrDomain, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country" | |
Write-Host '' | |
Write-Host 'Generating .p12 to import to Windows...' | |
& $keytool -importkeystore -srckeystore $KeystoreFile -destkeystore $P12Path -srcstoretype jks -deststoretype pkcs12 -srcstorepass $KeystorePassword -deststorepass $KeystorePassword | |
Write-Host '' | |
Write-Host 'Trusting generated SSL certificate...' | |
$secureStringKeystorePassword = ConvertTo-SecureString -String $KeystorePassword -Force -AsPlainText | |
$root = Import-PfxCertificate -FilePath $P12Path -Password $secureStringKeystorePassword -CertStoreLocation Cert:\LocalMachine\Root | |
Write-Host 'SSL certificate is now locally trusted. (added as root CA)' | |
Write-Host '' | |
Write-Host '########## NEXT STEPS ##########' -ForegroundColor Green | |
Write-Host '' | |
Write-Host '1. Copy your keystore to $SOLR_HOME\server\etc (MUST be here)' -ForegroundColor Green | |
if(-not $KeystoreFile.EndsWith('solr-ssl.keystore.jks')) { | |
Write-Warning 'Your keystore file is not named "solr-ssl.keystore.jks"' | |
Write-Warning 'Solr requires this exact name, so make sure to rename it before use.' | |
} | |
$KeystorePath = Resolve-Path $KeystoreFile | |
Write-Host '' | |
Write-Host '2. Add the following lines to your solr.in.cmd:' -ForegroundColor Green | |
Write-Host '' | |
Write-Host "set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks" -ForegroundColor Yellow | |
Write-Host "set SOLR_SSL_KEY_STORE_PASSWORD=$KeystorePassword" -ForegroundColor Yellow | |
Write-Host "set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks" -ForegroundColor Yellow | |
Write-Host "set SOLR_SSL_TRUST_STORE_PASSWORD=$KeystorePassword" -ForegroundColor Yellow | |
Write-Host '' | |
Write-Host 'Done!' |
Make sure to change the password in the parameter section:
[string]$KeystorePassword = '123456',
And make sure to update (keytool) path to the correct one:
$keytool = (Get-Command 'C:\Program Files\Java\jre1.8.0_171\bin\keytool.exe').Source
2. Open Powershell as an administrator and run this script.
· Go the script path and enter the below and click enter.
.\Solr-SSL.ps1 -keystorefile C:\solr-6.6.2\server\etc\solr-ssl.keystore.jks
3. Restart the Solr windows service.
Sitecore 9 installing packages
Go and install packages for XP Single (XP0) Instance configuration. Download packages for XP Single.
Copy the installation file and extract it to C:\Sitecore\Sitecore 9
Extract to the configuration file into the same path
Copy Sitecore license (license.xml) file to the same folder.
Make sure to update Solr paths in the below files:
- sitecore-solr.json
- xconnect-solr.json
Create a Powershell script for the installation and copy the below inside it on the same folder and name it ‘Installps.ps1’.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module SitecoreFundamentals | |
Import-Module SitecoreInstallFramework | |
#define parameters | |
$prefix = "sc900" | |
$XConnectCollectionService = "$prefix.xconnect" | |
$sitecoreSiteName = "$prefix.local" | |
$SolrUrl = "https://localhost:8983/solr" | |
$SolrRoot = "C:\solr-6.6.2" | |
$SolrService = "solr" | |
$SqlServer = "localhost" | |
$SqlAdminUser = "sa" | |
$SqlAdminPassword = "12345" | |
$SqlAccountUser = "$prefix" | |
$SqlAccountPassword = "Pa##w0rd" | |
$FilesRoot = "C:\Sitecore" | |
#install client certificate for xconnect | |
$certParams = | |
@{ | |
Path = "$FilesRoot\xconnect-createcert.json" | |
CertificateName = "$prefix.xconnect_client" | |
} | |
Install-SitecoreConfiguration @certParams -Verbose | |
#install solr cores for xdb | |
$solrParams = | |
@{ | |
Path = "$FilesRoot\xconnect-solr.json" | |
SolrUrl = $SolrUrl | |
SolrRoot = $SolrRoot | |
SolrService = $SolrService | |
CorePrefix = $prefix | |
} | |
Install-SitecoreConfiguration @solrParams -Verbose | |
#deploy xconnect instance | |
$xconnectParams = | |
@{ | |
Path = "$FilesRoot\xconnect-xp0.json" | |
Package = "$FilesRoot\Sitecore 9.0.0 rev. 171002 (OnPrem)_xp0xconnect.scwdp.zip" | |
LicenseFile = "$FilesRoot\license.xml" | |
Sitename = $XConnectCollectionService | |
XConnectCert = $certParams.CertificateName | |
SqlDbPrefix = $prefix | |
SqlServer = $SqlServer | |
SqlAdminUser = $SqlAdminUser | |
SqlAdminPassword = $SqlAdminPassword | |
SolrCorePrefix = $prefix | |
SolrURL = $SolrUrl | |
SqlCollectionUser = $SqlAccountUser | |
SqlCollectionPassword = $SqlAccountPassword | |
SqlMarketingAutomationUser = $SqlAccountUser | |
SqlMarketingAutomationPassword = $SqlAccountPassword | |
SqlReferenceDataUser = $SqlAccountUser | |
SqlReferenceDataPassword = $SqlAccountPassword | |
SqlProcessingPoolsUser = $SqlAccountUser | |
SqlProcessingPoolsPassword = $SqlAccountPassword | |
} | |
Install-SitecoreConfiguration @xconnectParams -Verbose | |
#install solr cores for sitecore | |
$solrParams = | |
@{ | |
Path = "$FilesRoot\sitecore-solr.json" | |
SolrUrl = $SolrUrl | |
SolrRoot = $SolrRoot | |
SolrService = $SolrService | |
CorePrefix = $prefix | |
} | |
Install-SitecoreConfiguration @solrParams -Verbose | |
#install sitecore instance | |
$sitecoreParams = | |
@{ | |
Path = "$FilesRoot\sitecore-XP0.json" | |
Package = "$FilesRoot\Sitecore 9.0.0 rev. 171002 (OnPrem)_single.scwdp.zip" | |
LicenseFile = "$FilesRoot\license.xml" | |
SqlDbPrefix = $prefix | |
SqlServer = $SqlServer | |
SqlAdminUser = $SqlAdminUser | |
SqlAdminPassword = $SqlAdminPassword | |
SolrCorePrefix = $prefix | |
SolrUrl = $SolrUrl | |
XConnectCert = $certParams.CertificateName | |
Sitename = $sitecoreSiteName | |
XConnectCollectionService = "https://$XConnectCollectionService" | |
SqlCoreUser = $SqlAccountUser | |
SqlCorePassword = $SqlAccountPassword | |
SqlMasterUser = $SqlAccountUser | |
SqlMasterPassword = $SqlAccountPassword | |
SqlWebUser = $SqlAccountUser | |
SqlWebPassword = $SqlAccountPassword | |
SqlFormsUser = $SqlAccountUser | |
SqlFormsPassword = $SqlAccountPassword | |
SqlProcessingTasksUser = $SqlAccountUser | |
SqlProcessingTasksPassword = $SqlAccountPassword | |
SqlReportingUser = $SqlAccountUser | |
SqlReportingPassword = $SqlAccountPassword | |
SqlMarketingAutomationUser = $SqlAccountUser | |
SqlMarketingAutomationPassword = $SqlAccountPassword | |
SqlReferenceDataUser = $SqlAccountUser | |
SqlReferenceDataPassword = $SqlAccountPassword | |
SqlProcessingPoolsUser = $SqlAccountUser | |
SqlProcessingPoolsPassword = $SqlAccountPassword | |
} | |
Install-SitecoreConfiguration @sitecoreParams -Verbose |
Make sure to put the correct values in the below variables:
- Root file ($FilesRoot = "C:\Sitecore\Sitecore 9").
- $SqlServer = "localhost"
- $SqlAdminUser = "sa"
- $SqlAdminPassword = "12345"
- Package = "$FilesRoot\Sitecore 9.0.0 rev. 171002 (OnPrem)_single.scwdp.zip"
- Package = "$FilesRoot\Sitecore 9.0.1 rev. 171219 (OnPrem)_xp0xconnect.scwdp.zip"
This script will create a DB user with the same name exists in this variable ‘$SqlAccountUser = "$prefix" which is in our example ‘sc900’, so please make sure to put a password on this variable $SqlAccountPassword = "Admin123" meets the password policy for your SQL server instance.
Open Windows PowerShell ISE as an administrator and open the script we created (Installps.ps1) and run the script.
If any error occurred during the installation, try to fix the error and remove the databases which are created during the installation, then re-run the script again.
Congrats! The installation is done, go and enjoy Sitecore 9.
0 comments:
Post a Comment