install Apache Solr 4.x for Drupal 7

Install Java 1.8 JDK

yum install java-1.8*
wget http://mirrors.sonic.net/apache/lucene/solr/4.10.2/solr-4.10.2.zip
mv apache-solr-4.10.2 apache-solr
wget http://ftp.drupal.org/files/projects/apachesolr-7.x-3.x-dev.tar.gz
tar xvfz apachesolr-7.x-3.x-dev.tar.gz

Now we are going to rename all the default Apache Solr config files

cd apache-solr/example/solr/conf/
mv schema.xml schema-01.xml
mv solrconfig.xml solrconfig-01.xml
mv protwords.txt protwords-01.txt

Next we’ll copy (and rename) all the Apache Solr Search Integration Drupal module config files into our Apache Solr installation at /usr/local/share/apache-solr/example/solr/conf/.

cp /usr/local/share/apachesolr/solr-conf/schema-solr3x.xml ./schema.xml
cp /usr/local/share/apachesolr/solr-conf/solrconfig-solr3x.xml ./solrconfig.xml
cp /usr/local/share/apachesolr/solr-conf/protwords.txt ./
cd pache-solr/example/
java -jar start.jar

Start Apache Solr automatically

vi /etc/init.d/solr

Paste this code (hit i key, and then paste via CTRL-SHIFT-V, or CTRL-V, or CMD-V — it all depends on your SSH client):

#!/bin/sh
 
# Starts, stops, and restarts Apache Solr.
#
# chkconfig: 35 92 08
# description: Starts and stops Apache Solr
 
SOLR_DIR="/usr/local/share/apache-solr/example"
JAVA_OPTIONS="-Xmx2048m -DSTOP.PORT=8079 -DSTOP.KEY=mustard -jar start.jar"
LOG_FILE="/var/log/solr.log"
JAVA="/usr/bin/java"
 
case $1 in
    start)
        echo "Starting Solr"
        cd $SOLR_DIR
        $JAVA $JAVA_OPTIONS 2> $LOG_FILE &
        ;;
    stop)
        echo "Stopping Solr"
        cd $SOLR_DIR
        $JAVA $JAVA_OPTIONS --stop
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
esac

assume your apache solr located in

/usr/local/share/

Now that’s done, we set the permissions and make our Apache Solr start automatically and shut down properly on reboot.

chmod 755 /etc/init.d/solr
chkconfig --add solr

And here are the available commands:

service solr start
service solr stop
service solr restart

Let’s start it

service solr start

Now you can

Install Drupal Solr module

Download and install Apache Solr Search Integration module as usual. It should install successfully. You can go and mess around with the settings and indexing or do that shit later after we’re fully done with the install…