Apache Solr Debian 9

2 minute read Modified:

Installing Apache Solr on Debian 9 (Stretch) for Drupal Search API.
Table of Contents

This is based on the howto of River Harbor and (regarding Java) slighty simplified. For using with Search API Solr backends for Drupal 7 or 8 you can install Apache Solr on a Debian 9 (Stretch) server with the following steps:

Java Runtime Environment (JRE)

First the Java Runtime Environment (JRE) has to be installed on the system:

apt-get update -y && apt-get upgrade -y
apt-get install default-jre-headless

It’s possible to install the Java Development Toolkit (JDK) instead, since it also contains the JRE. Normally this is only necessary for Java development or to compile components. For just running Apache Solr, installing JRE is sufficient.

Installing Solr

The most recent 6.x version of Solr can be found here. Install as root as follows (replace version number 6.6.2 if necessary):

cd /tmp
wget https://archive.apache.org/dist/lucene/solr/6.6.2/solr-6.6.2.tgz
tar xzf solr-6.6.2.tgz solr-6.6.2/bin/install_solr_service.sh --strip-components=2
./install_solr_service.sh solr-6.6.2.tgz
service solr status

Now the output should show that the Solr service is running. By default Solr listens on port 8983. The firewall should be configured that this port is only accessible from localhost (if the Drupal installation is running on the same machine). Careful: The port should not be accessible from anywhere!

Configuring Solr

su - solr -c "/opt/solr/bin/solr create -c drupal -n data_driven_schema_configs"

This created the search core “drupal” and Apache Solr is accessible under http://youripaddress:8983/solr/ (watchout for firewall). Now copy the config files that came with the search_api_solr module:

cp sites/all/modules/search_api_solr/solr-conf/6.x/* /var/solr/data/drupal/conf/
service solr restart

In the Drupal Search API config you can create a new server:

  • Server name: choose one
  • Service class: Solr service
  • Solr host: <hostname>
  • Solr port: 8983
  • Solr path: /solr/drupal