Installing Apache Solr on Windows Server 2008

This entry is in addition to Drupal + Solr Search on Linux.  If you are unsure of where to get Solr, refer to that entry. There are two ways of getting Solr Search running on a Windows server. The first is using Tomcat or Jetty and the other is starting Solr by running the java -jar start.jar. The latter works, but the issue is that we need to run it as a service. No matter how you slice it, you will need to install Java on the server. Download the JDK from Oracle's website (http://www.oracle.com/technetwork/java/javase/downloads/index.html) and install it.

The Manual Way
Download Apache Solr, which includes the Jetty web server. Once the file has finished downloading, extract the contents and rename the directory example to C:\solr At this point, you can run open up PowerShell or a command prompt, change the directory to C:\solr and run the following command:

java -jar start.jar

This is all fine and dandy, if you log out the process will terminate and search requests will not be fulfilled. We need to create a service and the easiest way to do that is using a tool called NSSM - Non Sucking Service Manager. This tool will make creating the services a lot easier than trying to use the sc command. You can download it by going to http://nssm.cc/download/?page=download

Copy the appropriate nssm (32 or 64 bit) binary into the C:\solr directory. Navigate to that directory using PowerShell or a command prompt and run the following command:

> nssm install solr

A new window will be displayed on your screen asking you for the following information. 

  • Application
    • C:\Windows\System32\java.exe
  • Options
    • -Dsolr.solr.home=C:/solr/solr -Djetty.home=C:/solr/ -Djetty.logs=C:/solr/solr/logs/ -cp C:/solr/lib/*.jar;C:/solr/start.jar -jar C:/solr/start.jar

If the service doesn't start, or Solr is having issues finding config files, stop it and delete the service:

> sc delete solr

 

Using Tomcat
Download Tomcat6 and run the install file. Assuming that you left the install path alone, Tomcat will be installed to C:\Program Files\Apache Software Foundation\Tomcat 6.0

  • Copy solr.war file from the example directory to C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps
  • Copy the solr directory to C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps
  • Go to Start -> All Programs -> Apache Tomcat 6.0 Tomcat6 -> Monitor Tomcat
  • In the Java tab, add the following parameters to the Java Options text area
    • -Dsolr.solr.home=c:\web\solr
    • -Dsolr.velocity.enabled=false
  • Restart Tomcat