Sitecore Box

Sitecore web developer at Americaneagle.com

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 platform installerUse this for installing the following software:
-      Web Deploy 3.6 for Hosting Servers.
-      URL Rewrite 2.1 (Use Web Platform Installer to install).


·        We need to have Java runtime installed

-      Click here and accept the license then choose your platform.



-      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

-   To complete the setup for Solr as https, we need to install OpenSSL, click here and install it.

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:

1.    Download NSSM. And extract it to (C:\nssm-2.24\win64).

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).


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.

4.    Make sure that the Solr is running using SSL by opening this URL https://localhost:8983/solr





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’.


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.

Sitecore Media Items Extensions and SEO


Introduction

Sitecore stored all media URLs that referenced inside RTE (Rich Text Editor) with .ashx extension. This will may cause a problem with old browsers that use the extension instead of applying the MIME type in the HTTP response header, and also for SEOs that allow filtering results by extension.


How to use the original extension?

A.   Change the settings for the uploaded files in the future.

To solve this problem we need to update the configuration for Sitecore to use the original file extensions rather than .ashx. To do so we need to update ‘Media.RequestExtension’ setting in config file.

What we should have to do is create new config file contains the below content and put the file under App_Config\Include folder:


B. How to force the RTE to add item extension instead of .ashx?

The big challenge here is how to update all media links which are already stored in RTE or File fields?

The below code snippet will solve this issue by looping on all items which have media links with .ashx extension and replace the extension with the original one: