How to Install Apache Solr 6 on Drupal 7

How to Install Apache Solr 6 on Drupal 7

Here's how I've managed to get Apache Solr 6.5.x on Ubuntu 16.04LTS working in Drupal 7. Borrowed some very helpful instructions from HowToForge.com and tweaked for our purposes. 

The instructions below will install python, and java runtime and the latest solr instance. Yes, as of this writing, Solr 6.x is compatible with Drupal 7 and Search API.

 If you have a better or updated method, please sound off in the comments. 

INSTALL PYTHON COMPONENTS AND JAVA RUNTIME ENVIRONMENT:

  1. sudo apt-get update && sudo apt-get upgrade -y
  2. sudo apt-get install python-software-properties -y
  3. sudo add-apt-repository ppa:webupd8team/java
    • Did you get a error something like: sudo: add-apt-repository: command not found?
    • If so, then run:  sudo apt install software-properties-common -y
    • Then repeat step #3 or sudo add-apt-repository ppa:webupd8team/java 
  4. sudo apt-get update
  5. sudo apt-get install oracle-java8-installer -y
    • Agree to Terms to Continue.
  6. test to ensure java is running with:  java -version

INSTALL SOLR: 

  1. cd /tmp
  2. wget http://www.us.apache.org/dist/lucene/solr/6.x.x/solr-6.x.x.tgz  
    • where "x" = latest version found here   
    • replace "x" with latest 6.x version.
  3. tar xzf solr-6.x.x.tgz solr-6.x.x/bin/install_solr_service.sh --strip-components=2
    • Again, where "x" = latest/downloaded version.
  4. sudo ./install_solr_service.sh solr-6.x.x.tgz
  5. service solr status
    • Should show results similar to: solr.service - LSB: Controls Apache Solr as a Service Loaded: loaded (/etc/init.d/solr; bad; vendor preset: enabled.  Active: active (exited) since Thu 2017-04-27 11:12:31 EDT; 19s ago, Docs: man:systemd-sysv-generator(8)

NOW WE GET DRUPAL SPECIFIC WITH OUR SOLR INSTALL. CREATE A CORE/COLLECTION:

  1. Go to your firewall settings and open up port 8983. We'll leave this open while we complete installation although we will secure it afterwards.
    • If using UFW for your firewall for example:  sudo UFW allow 8983
  2. sudo su - solr -c "/opt/solr/bin/solr create -c drupal -n data_driven_schema_configs"
  3. Test Your New Solr Instance by entering your IP address:8983/solr in your browser.
  4. Install and enable the Drupal Search API modules you want including Search API Solr.
  5. Once the Search API Solr module is installed, you'll need to go to sites/all/modules/search_api_solr/solr-conf/6.x/  and copy all the files from this directory to /var/solr/data/drupal/conf/   (this directory was automatically created when we created the core collection above).
    • sudo cp sites/all/modules/search_api_solr/solr-conf/6.x/*.* /var/solr/data/drupal/conf/
    • confirm files copied: sudo ls /var/solr/data/drupal/conf

ALMOST DONE. LET'S CONFIGURE DRUPAL & THE SEARCH API SOLR MODULE.

  1. Once your modules are installed, enabled, and the schema files from the module have been copied over to the solr instance as outlined in the previous step, go to the Search API module in your Drupal site and create a new Solr server.
    1. Under Server Name.. Call it whatever you like Ex: "Solr Server"
    2. Under Solr Service section
      • Select http or https if you have SSL enabled. Not req'd.
      • Under Solr Host. Drop in your server's IP Address or Fully Qualified Domain Name.
      • Solr Port:  8983
      • Solr Path: /solr/drupal
    3. Save
    4. Here's where things might get a little messy for a minute. No worries. If you get an error message that you're using an incompatible schema files, here's what to do.  Remember that Solr Dashboard earlier in this guide? We're going to revisit it.
      1. Pull up your browser and go to your IP Address:8983/solr  (reminder: port 8983 should be open for this, for now)
    5. Go back to your search api module server settings and hit save again. 
    6. YOU ARE DONE!!!
    7. Now that you're up and running, let's lock that Solr Dashboard down.
      • Go to your firewall and deny all access to port 8983 with the exception of either your localhost or your server's IP Address.  
      • sudo ufw deny 8983 (if using UFW).
      • sudo UFW allow from http://youripaddress or localhost to any port 8983
      • If not using UFW, take a look at this Article .
    8. You can go on to create your search index or indicies and enjoy having a smooth Apache Solr instance on your Drupal 7 site.

Enjoy. Hope this helps out. 

Add new comment