How To Setup A Local Solr Server For Search API

Want to learn more about search in Drupal 7? Then check out our online video course called “Build Powerful Search Pages with Views and Search API in Drupal 7“.

Running Search API and Apache Solr just got easier thanks to the latest release of the Search API Solr search module. This module allows you to use Solr as a server backend for Search API indexes. In the latest release (7.x-1.0-rc4) the module no longer has a dependency on the SolrPhpClient library.

In this tutorial I’ll show you how to setup a local development Solr server on Mac OS X 10.8.3.

Please note that this tutorial should only be used to setup a development server where you’re not worried about locking down Solr. If you want to setup Solr for a production site, then make sure you lock down the server so users can not get access to Solr.

Step 1: Check Java

First, check and make sure Java is installed. Open the Terminal app and enter java -version, if the version is 1.6 you’re good to go.

Fig 1.1

Step 2: Download Search API Solr Module

Download and install the Search API Solr search module for Search API.

If you use Drush, run the following command:

$ drush dl search_api_solr

Step 3: Download Solr

Before we begin, download Solr (3.x) and extract the tar or zip file somewhere on your filesystem. Currently, only Solr 3.x is supported so don’t download the 4.x version.

Fig 1.2

Step 4: Configure Solr

Go to where you extracted Solr and duplicate the example folder. Rename the duplicated folder drupal-search. You can call the folder whatever you want just make it descriptive.

Fig 1.3

Go to the Search API Solr module and copy the files in the search_api_solr/solr-conf/3.x folder into drupal-search/solr/conf within Solr itself.

Fig 1.4

Step 5: Start Solr

Now we have everything setup it’s time to start Solr. We need to run Solr from the Terminal App, so open Terminal and go to the Solr directory.

Go into the drupal-search folder and run java -jar start.jar.

Fig 1.5

To see if Solr is working, go to http://localhost:8983/solr/admin/ and you should see the Solr administration page.

Fig 1.6

Step 6: Create Search API Server

The last and final step is to create a Solr Search API server for our index.

1. Go to Configuration -> “Search API” and click on “Add server”.

2. In the text field “Server name” enter “Solr server” and from the “Service class” drop-down list select “Solr service”.

Fig 1.7

3. Leave all the Solr settings as is and click on “Create server”.

Fig 1.8

4. When you create an index, make sure you select “Solr server” from the Server drop-down list.

Fig 1.9

If you want to learn how to use Search API please read “Intro To Search API (Part 1) – How To Create Search Pages” and “Intro To Search API (Part 2) – Faceted Search“.

If you have any questions, please leave a comment.

10 thoughts on “How To Setup A Local Solr Server For Search API”

  1. I wonder if normally shared hosting with cpanel or Direct Admin has usually Apache Solr installed? How to know whether a hosting is running on Apache Solr? Will it indicate in phpinfo.php ? Thanks.

    1. Apache Solr runs separately to PHP. You can’t just view phpinfo.php and see if it’s installed.

      Your shared hosting provider needs to offer it.

  2. Hi! I’d like to say thank you for all of these tutorials, it really helped me. But in Drupal is it possible to use the data coming from Solr in Drupal so that I could display it in a search page?


    Hi Ivan
    Thank you for the tutorial
    On Step 5: Start Solr

    “Go into the drupal-search folder and run java -jar start.jar.”

    Once I get solr running.
    How do you exit it from the command line?
    I’ve tried Crtl + C
    This exit but switch’s off solr too

    Many Thanks for your help

  4. Hi
    I am debating whether to set up a local instance of Apache Solr – using your solution – or whether to go straight to a hosted solution, e.g., to save any deployment issues. Ideally, I would like to develop locally first.

    My question is, for a new comer to Apache Solr, is it straightforward to change from a local Apache Solr instance to a hosted solution? I have deployed local Drupal sites to hosting without issue, but including Apache Solr search is an unknown. Any advice would be appreciated.

    1. “is it straightforward to change from a local Apache Solr instance to a hosted solution”

      It depends. I’ve never used so I can’t comment. But when you’re ready to move to a hosted solution it should be as simple as copying over the Solr configuration.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top