Starting from the beginning: Installing Sitecore 9

Wanting to get into Sitecore? Don’t know how to begin? Well, I once had a professor at college that always asked: “where do we begin? At the beginning”. While it may sound obvious, in Sitecore we begin with setting up our local development environment. As of the date of this post, Sitecore 9.1 has been announced to be released soon, but while we
wait, we’ll do this installation with Sitecore 9 Update 2.

Installation

Turn on IIS

It could be that you’ll already had set up IIS for developing in ASP.NET and so. But in my situation, I was using my computer mostly for learning development for Angular and Vue, and .NET Core, so I weren’t in need for IIS. Now with this Sitecore installation, we need it, so lets turn the IIS and other related features on.

  1. Go to Control Panel > Programs > Turn Windows features on or offStep1WindowsFeatures
  2. Check all the options shown in the images belowWindowsFeatures1WindowsFeatures2
  3. Click “Next” and all of the features will be installed

SQL Server

Installation for SQL Server and the Management Studio should be pretty straightforward. Still there is some configuration in terms of security that it needs to be done before the Sitecore installation.

    1. Go to management studio and log in into your local server. On the Object Explorer, right click on the server and select the “Properties” option.SQL1
    2. Go to the “Security” section and change “Server authentication” to “SQL Server and Windows Authentication mode” and press “OK”. You’ll get a message that SQL Server needs to be restarted for changes to take effect.SQL2SQL3
    3. On the Object Explorer, right click again and select “Restart”. On the confirmation window, click “Yes”.SQL4SQL5
    4. Expand the “Security” folder” , right click on the “Login” folder and select “New Login…”SQL6
    5. On the New login window, select “SQL Server authentication”. Enter a name, password and a password confirmation (remember that password for later). Deselect the rest of the check-marks below:SQL7
    6. Go to the “Server Roles” section to select the roles for the user (I select all of them just in case, since I’m not that good of a DBA. We can go back later and change the roles)SQL8
    7. Press the “OK” button for the account to be created. To be sure that everything went well, try login in to the database server with the newly created account.

Java setup for Solr

  1. Installation for Java JDK should be straightforward also. After you install the JDK, that is needed for Solr, there is one more step before we start setting up Solr.
  2. Go to Control Panel>System and Security>System and select “Advanced system settings” from the left section. On the opened window, press the “Environment Variables” button at the bottom.Java1Java2
  3. Under “System Variables”, click “New”. In the “Variable name” field, enter “JAVA_HOME”. On the “Variable value” enter the JDK installation path (the one on the image below is the default, if you changed it, enter your custom installation path). Click “OK” through the opened windows to apply the changes.Java3

Solr+SSL & NSSM

  1. Extract the contents inside the folder of the downloaded the NSSM zip file in any path (I chose “C:\Program Files\nssm”). For solr, extract the folder inside the downloaded zip file in any path (for this I chose
    “C:\solr-6.6.2”).
  2. For Solr we need first to create an SSL certificate. To do that, open a Powershell window (as Administrator) and enter the following command to create a self signed certificate:
    New-SelfSignedCertificate -CertStoreLocation cert:\LocalMachine\My -DnsName "localhost", "127.0.0.1" -FriendlyName "SolrCert" -NotAfter (Get-Date).AddYears(10)
  3. Open the MMC to add the certificate (Windows search “Manage computer certificates”).
  4. On MMC, OPEN THE Personal-> Certificates Node on the left pane and right click on the created certificate. Copy that certificate to the “Trusted Root Certification Authorities”.Sorl6Sorl7
  5. Right click the certificate and on the menu select “All Tasks>Export”.
  6. On the second screen, select “Yes, export the private key”. Click Next.
  7. Select the option “Include II certificates in the certification path if possible” if it’s not selected already and click Next.
  8. Select the “Password” checkbox, enter and confirm a password. Write it down because you’ll need it for another step later on.
  9. Select a location for the creation of the PFX file (I save it on the “C:\solr-6.6.2\server\etc” location). Click next to finish the wizard.
  10. On the Solr folder, go to the “C:\solr-6.6.2\bin” and open the solr.in.cmd file in any text editor and uncomment the following
    REM Uncomment to set SSL-related system properties
    REM Be sure to update the paths to the correct keystore for your environment
    set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks
    set SOLR_SSL_KEY_STORE_PASSWORD=secret
    set SOLR_SSL_KEY_STORE_TYPE=JKS
    set SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks
    set SOLR_SSL_TRUST_STORE_PASSWORD=secret
    set SOLR_SSL_TRUST_STORE_TYPE=JKS
    set SOLR_SSL_NEED_CLIENT_AUTH=false
    set SOLR_SSL_WANT_CLIENT_AUTH=false

     

  11. Change the values to the following:
    set SOLR_SSL_KEY_STORE=C:/apache/solr_ssl_cert.pfx
    set SOLR_SSL_KEY_STORE_PASSWORD=secret
    set SOLR_SSL_KEY_STORE_TYPE=PKCS12
    set SOLR_SSL_TRUST_STORE=C:/apache/solr_ssl_cert.pfx
    set SOLR_SSL_TRUST_STORE_PASSWORD=secret
    set SOLR_SSL_TRUST_STORE_TYPE=PKCS12

     

  12. To test the Solr installation with the SSL enter the following command on the Command prompt “C:\solr-6.6.2\bin\solr.cmd -p 8983″. Enter then the URL ” https://localhost:8983/solr/ ” o any browser to see Solr running with SSL. After confirming that is running, you can stop Solr with the following command
    “C:\solr-6.6.2\bin\solr.cmd stop -all”.
  13. Now we’ll set up Solr as a Windows service. Open a Command prompt (on Administrator mode, just in case), and enter the following command: “c:\Program Files\nssm\win64\nssm” install solr6
  14. Click on the “…” button to search for the “solr.cmd” path as seen on the image below. Also add the values on the “Arguments” field.Sorl
  15. Click on the “Details” tab to add the following (while this is optional, it still good to set up). After that click on “Install service”Sorl2Sorl3
  16. Go to the Services window to check if the services is running (Windows search “services”). If it’s listed but not on status “Running” just right click on the service and select “Start”.Sorl4
  17. Go to this URL: https://localhost:8983/solr/#/ to make sure Solr is running.Sorl5

Web Deploy and URL Rewrite

  1. Download and install Web Deploy (in my case it said that a newer version was found on my machine, but it doesn’t hurt for you to try).
  2. Download and install the IIS extension for URL Rewrite. The installation is straightforward. After the installation, you should see “URL Rewrite” on the IIS.urlrewrite

Sitecore 9

So finally we get to the interesting part, installing Sitecore 9 (Update 2 to be precise). Before we get to the good stuff, there’s still some prerequisites for installing the packages.

    1. Open a Powershell window (admin mode) and enter the following command to register the repository:
      Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2
    2. Then, enter this command to install the Sitecore Installation Framework:
      Install-Module SitecoreInstallFramework
    3. Extract the files from the zip package into a folder (mine for example is extracted in “C:\resourcefiles”. Inside that folder, extract the files from the “XP0 Configuration files…” zip file.
    4. Add the “License.xml” file that has been provided by Sitecore.
    5. Copy paste the following code into a powershell file (extension “.ps1”). This script was generated using the SFILess software. For the sake of time, we will skip using the program to create the script. If you want to know more about it, download here.
      
      param (
          [switch]$uninstall
      );
      
      
      $start = Get-Date
      
      #Requires -Version 5.1
      #Requires -RunAsAdministrator
      #Requires -Modules SitecoreInstallFramework
      #Requires -Modules SitecoreFundamentals
      
      
      Import-Module SitecoreInstallFramework
      
      $Prefix = 'sitecore9Ignition'
      $PSScriptRoot = 'C:\resourcefiles'
      $SolrUrl = 'https://localhost:8984/solr'
      $SolrRoot = 'C:\Projects\Solr\solr-6.6.2'
      $SolrService = 'Solr6.2'
      $SqlServer = 'HCTX-LTB7071N2'
      $SqlAdminUser = 'test'
      $SqlAdminPassword = '84528452'
      $LicenseFilePath = 'C:\resourcefiles\license.xml'
      $xConnectCertName = "$Prefix.xconnect_client"
      $xConnectSiteName = 'sitecore9Ignition.xconnect'
      $SiteName = 'sitecore9Ignition.sc'
      $SiteFolder = "C:\inetpub\wwwroot\$SiteName"      
      $xConnectSiteFolder = "C:\inetpub\wwwroot\$xConnectSiteName"
      $SecurePassword = 'Sitecor3SecureP4ssword!'
            
      
      if($uninstall)
      {
      	function RemoveService([string]$serviceName){
          $service = Get-Service $serviceName -ErrorAction SilentlyContinue
          
          if($service){
            Write-Host "Removing Service '$serviceName'"
            if($service.Status -ne "Stopped"){
              Write-Host "Stopping Service '$serviceName'"
                Stop-Service $serviceName
            }
          
            sc.exe delete $serviceName #in Powershell 6, this will be nicer...
            Write-Host "Removed Service '$serviceName'"
          }
          else {
            Write-Host "Service not found '$serviceName'"
          } 
        }
      
        function RemoveSolrCores(){
          $client = (New-Object System.Net.WebClient)
          [xml]$coresXML = $client.DownloadString("$SolrUrl/admin/cores")
          $cores = $coresXML.response.lst[2].lst | % {$_.name}
          $success = 0
          $error = 0
          
          foreach ($core in $cores) {
            if ($core.StartsWith($prefix)) {
              $url = "$SolrUrl/admin/cores?action=UNLOAD&deleteIndex=true&deleteInstanceDir=true&core=$core"
              Write-Host "Deleting Core: '$core'"
              $client.DownloadString($url)
              if ($?) {$success++}
              else{ $error++}
            }
          }
          write-host "Deleted $success cores.  Had $error errors."
        }
      
        function RemoveDatabase([string]$dbName){
          Write-Host "Removing Database '$dbName'"
          Invoke-SQLCmd -ServerInstance $SqlServer -U $SqlAdminUser -P $SqlAdminPassword -Query "IF EXISTS(SELECT * FROM sys.databases WHERe NAME = '${prefix}_$dbName') BEGIN ALTER DATABASE [${prefix}_$dbName] SET SINGLE_USER WITH ROllBACK IMMEDIATE; DROP DATABASE [${prefix}_$dbName];END"
        }
      
          function RemoveWebsite([string]$site){
          Write-Host "Removing Site '$site'"
          $webSite = Get-Website -Name $site -ErrorAction SilentlyContinue
          $sitePath = $webSite.PhysicalPath
          if($webSite){
            Stop-Website -Name $site
           
            Remove-Website -Name $site
      
            Write-Host "Removing Application Pool '$site'"
            Remove-WebAppPool -Name $site 
          }
          else {
            Write-Host "Site not found '$site'"
          }
        }
      
      	
        function RemoveFolder([string]$path){
      	  if(Test-Path -Path $path){
      		   Write-Host "Removing Folder '$path'"
      			&cmd.exe /c rd /s /q $path
      	  }
      	  else{
      		  Write-Host "Folder not found: '$path'"
      	  }
         
      
          if(Test-Path -Path $path)      {
            Write-Error "Failed to delete site folder '$path'"
        }
      
        }
      
      
      	
           
        RemoveService("$xConnectSiteName-MarketingAutomationService")
        RemoveService("$xConnectSiteName-IndexWorker")
        
        RemoveSolrCores
        
        RemoveDatabase("Core")
        RemoveDatabase("EXM.Master")
        RemoveDatabase("ExperienceForms")
        RemoveDatabase("MarketingAutomation")
        RemoveDatabase("Master")
        RemoveDatabase("Messaging")
        RemoveDatabase("Processing.Pools")
        RemoveDatabase("Processing.Tasks")
        RemoveDatabase("ReferenceData")
        RemoveDatabase("Reporting")
        RemoveDatabase("Web")
        RemoveDatabase("Xdb.Collection.Shard0")
        RemoveDatabase("Xdb.Collection.Shard1")
        RemoveDatabase("Xdb.Collection.ShardMapManager")
        
        RemoveWebsite($xConnectSiteName)
        RemoveWebsite($SiteName)   
        
        RemoveFolder($SiteFolder)
        RemoveFolder($xConnectSiteFolder)   
              
      }
      else
      {
      	
                
              if(-not (Get-command npm)){
                Write-Host "NPM not detected"
                Return
              }
              
        $certParams = @{
          Path = "$PSScriptRoot\xconnect-createcert.json"
          CertificateName = $xConnectCertName 
        }
        Install-SitecoreConfiguration @certParams -Verbose
          
        $solrParams = @{
          Path = "$PSScriptRoot\xconnect-solr.json"
          SolrUrl = $SolrUrl
          SolrRoot = $SolrRoot
          SolrService = $SolrService
          CorePrefix = $Prefix
        }
        Install-SitecoreConfiguration @solrParams
        
        $xconnectParams = @{
          Path = "$PSScriptRoot\xconnect-xp0.json"
          Package = "$PSScriptRoot\Sitecore 9.0.2 rev. 180604 (OnPrem)_xp0xconnect.scwdp.zip"
          LicenseFile = $LicenseFilePath
          Sitename = $xConnectSiteName
          XConnectCert = $xConnectCertName 
          SqlDbPrefix = $Prefix
          SqlServer = $SqlServer
          SqlAdminUser = $SqlAdminUser
          SqlAdminPassword = $SqlAdminPassword
          SolrCorePrefix = $Prefix
          SolrURL = $SolrUrl
          SqlCollectionPassword = $SecurePassword
          SqlProcessingPoolsPassword = $SecurePassword
          SqlReferenceDataPassword = $SecurePassword
          SqlMarketingAutomationPassword = $SecurePassword
          SqlMessagingPassword = $SecurePassword
        }
        Install-SitecoreConfiguration @xconnectParams
        
        $solrParams = @{
          Path = "$PSScriptRoot\sitecore-solr.json"
          SolrUrl = $SolrUrl
          SolrRoot = $SolrRoot
          SolrService = $SolrService
          CorePrefix = $Prefix
        }
        Install-SitecoreConfiguration @solrParams
          
        $sitecoreParams = @{
          Path = "$PSScriptRoot\sitecore-XP0.json"
          Package = "$PSScriptRoot\Sitecore 9.0.2 rev. 180604 (OnPrem)_single.scwdp.zip"
          LicenseFile = $LicenseFilePath
          Sitename = $SiteName
          XConnectCert = $xConnectCertName 
          SqlDbPrefix = $Prefix
          SqlServer = $SqlServer
          SqlAdminUser = $SqlAdminUser
          SqlAdminPassword = $SqlAdminPassword
          SolrCorePrefix = $Prefix
          SolrURL = $SolrUrl
          SqlCorePassword = $SecurePassword
          SqlMasterPassword = $SecurePassword
          SqlWebPassword = $SecurePassword
          SqlReportingPassword = $SecurePassword
          SqlProcessingPoolsPassword = $SecurePassword
          SqlProcessingTasksPassword = $SecurePassword
          SqlReferenceDataPassword = $SecurePassword
          SqlMarketingAutomationPassword = $SecurePassword
          SqlFormsPassword = $SecurePassword
          SqlExmMasterPassword = $SecurePassword
          SqlMessagingPassword = $SecurePassword
          XConnectCollectionService = "https://$xConnectSiteName"
        }
        Install-SitecoreConfiguration @sitecoreParams
              
      }
      
      
      $timeSpan = New-TimeSpan -Start $start -End (Get-Date)
      
      Write-Host ("SIF-less completed in {0:HH:mm:ss}" -f ([datetime]$timeSpan.Ticks))
      

       

    6. Change the following values in the script:
      1. $Prefix = ‘sitecore9’ – prefix for all your Sitecore installation.
      2. $PSScriptRoot = ‘C:\resourcefiles’ – location of the script and the installation files (don’t change if it’s the same I suggested).
      3. $SolrUrl = ‘https://localhost:8983/solr’ – URL of the Solr instance.
      4. $SolrRoot = ‘C:\solr-6.6.2’ – physical location of Solr.
      5. $SolrService = ‘solr6’  – The name of the Solr service in the Windows Services list.
      6. $SqlServer = ‘HXOUNH’ – Name of the SQL Server instance.
      7. $SqlAdminUser = ‘sc_user’ – SQL user created earlier for Sitecore databases creation.
      8. $SqlAdminPassword = ‘123456’ – Password for the SQL user created earlier for the Sitecore
        databases creation.
      9. $LicenseFilePath = ‘C:\resourcefiles\license.xml’ – path of the Sitecore license file. For simplicity, we put it in the same folder as the resource files.
      10. $xConnectSiteName = ‘sitecore9’ – name of your Sitecore xConnect instance.
      11. $SiteName = ‘sitecore9’ – name of your Sitecore instance.
    7. Go to the resourcefiles path in powershell and enter the following command:
      “.\SIFless-EZ.sitecore9.ps1” and press enter.
    8. Wait around 10-15 minutes for the whole installation to be completed. After that, check on your IIS that the Sitecore and xConnect sites have been created and browse to the Sitecore site to see that everything looks good.

If everything looks good, now it’s a good time to start messing around Sitecore. Happy development!

References

While I put together this post, I had some good references for installing Sitecore 9. Here are some of them:

Advertisements

One thought on “Starting from the beginning: Installing Sitecore 9

Leave a Reply

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.