How to install Apache Solr 5.x for use with Drupal

Here's the updated version on how-to install Apache Solr 5.x and get it running with Drupal (WITHOUT Apache Tomcat; as Solr 5.x doesn't support Tomcat anymore).

Install Java 1.8

yum install java-1.8.0-openjdk.x86_64
# or
aptitude install java8-jdk

Create a symlink to wherever your /etc/bashrc or ~/.bashrc has

export JAVA_HOME=/usr/local/jdk

set to.

systemctl status solr
#or
service solr status

Setup Apache Solr for Drupal

Get the latest Apache Solr Search and install the module as usual into your drupal installation.

cd DRUPAL_INSTALLATION
drush dl apachesolr --dev -y; drush en apachesolr_access, apachesolr, apachesolr_search -y;

Get the drupal apache Solr 5.x configuration files and copy them over to Solr configuration directory:

cd DRUPAL_INSTALLATION/sites/all/modules/contrib/
wget http://ftp.drupal.org/files/projects/search_api_solr-7.x-1.x-dev.tar.gz
tar xzvf search_api_solr-7.x-1.x-dev.tar.gz
#or
drush dl search_api_solr --dev -y
mkdir -p /var/solr/data/drupal/conf
cp search_api_solr/solr-conf/5.x/* /var/solr/data/drupal/conf
chown -R solr:solr /var/solr /opt/solr

Now we create an Solr 5.x core for drupal--which we'll use the conf files copied over from above.

sudo /opt/solr/bin/solr create -c drupal

Add your server IP and YOUR IP to the Solr server whitelist

vi /opt/solr/server/etc/jetty.xml

Search for:


Replace with:



  
    127.0.0.1
  
  
    YOUR.IP.ADDRESS.HERE
  
  
    
  


Start Solr server

systemctl start solr.service
or
service solr start

That should take care of the hard part...

We can check Apache Solr interface here: http://localhost:8983/solr/#/

NOTE: The URL you're going to put in for Drupal's Apache Solr Search module is this:

http://127.0.0.1:8983/solr/drupal

After all this, you'll probably also want to install Drupal's Search API Solr search

So that's it, and that's that...

Don't forget to firewall protect port 8983 from public access. You can use CSF for that.

Tags: apache apache solr Drupal Server admin