Apache Solr is not a Drupal module, but a server application like Varnish or MySQL. Before we can use Solr with Drupal, we must plan how we will deploy Solr to our production site.
In this tutorial, we'll:
- List the requirements for Solr installation
- Identify when to install Solr on new hardware
- Describe various installation methods
Understand the system requirements and general installation steps for installing Apache Solr on a Linux-based web server.
- A general understanding of the command line and managing a Linux-based web server.
Solr can require substantial computing resources depending on the number of documents (nodes) you need to index, the number of fields for each node, and the amount of searches you expect to run. As every Drupal site will have different search demands, the amount of additional resources necessary is highly variable.
In general, you will want at least:
- 1GB free of memory
- 1 CPU core for each major process on the server
Like the database, Solr can be installed on a standalone server, or on the same server as the web server. For a standalone Solr server, 1 CPU core is enough to start. If Solr is to be installed on the same server as the web server, a minimum of 2 cores is recommended (one for Solr, and one for the web server).
Solr, like Drupal, isn't a standalone executable. It needs a runtime environment in order to function. For Drupal, it's PHP. For Solr, it's Java. For most commodity Linux servers, Java is either pre-installed, or easily installed via the distribution's default package manager.
You can check if Java is installed by running the following command:
If the command displays a version, Java is installed. If it returns
Command not found, you will need to install Java.
Java is available in a few different distributions. The largest split is between Oracle Java and OpenJDK. The former is considered the official distribution of Java and is supported by Oracle. You may also see this referred to as "Sun Java" referring to the previous maintainer, Sun Microsystems.
Due to licensing reasons, many Linux distributions do not ship with Oracle Java out of the box, and instead ship a fully open source version of Java, called OpenJDK. Solr works equally well with Oracle Java and OpenJDK. This tutorial will assume OpenJDK, although there will be no distinction to the Drupal developer.
Solr 6.x and 7.x both require at least Java Runtime Environment (JRE) 1.8. Often this will be referred to as "Java 8" or "Java SE 8".
Once the correct version of Java is installed, we're ready to install Solr. While many distributions of Linux will offer a package to install Solr, it is recommended you download the latest version of Solr directly from lucene.apache.org/solr. This will provide you the most flexibility going forward.
While the official Solr documentation can give you detailed steps for installing and configuring Solr, in general the process is as follows:
- Create a new
solruser under which to run Solr and own the files.
- Download and extract the Solr files to /opt/solr.
- Start the Solr server using
- Use system utilities to configure the Solr server to start at boot-up.
By default, Solr will provide an admin interface on port 8983 of whatever server it is installed upon. You can visit the admin interface by navigating to the following address:
Note that there is no login for this interface. You can configure the Admin UI to require an HTTPAuth login, but many will choose to block all access to the Solr port to prevent tampering.
Solr is a server application which relies on Java. In order to run Solr, we first need to install Java, create a Solr user, and then download and extract the Solr software package.
Further your understanding
- Does Search API require specific versions of Solr?
- Official Solr documentation (lucene.apache.org)