blog-banner

Configure Apache Solr With Tomcat

    Apache Server With Tomcat

    Many times Drupal Architects prefer to go with Apache Solr instead of Drupal core search. I am no outlander to this scenario, but this time it was a new requirement. By default, the Apache Solr relies on the Jetty server to index and retrieve items during the search. My need was to use the Tomcat server in the place of Jetty. The first glance proved it was an easy task, but later the tough fight started.

    Initially, I had references from many sites about how to integrate Apache Solr with Tomcat. Alas, none had the elucidation to provide an end-to-end solution. Hence I would like to write one on my own.

    Downloading and Starting Tomcat

    Step 1: Download the Apache Tomcat Server from its official site. I would insist you do this rather than installing it via the packet manager.

    Step 2: Extract the folder in the /usr/share/. In a multi-site environment, this would help to run the tomcat as a single instance.

    Step 3: Now get into the Tomcat folder and see for the bin folder. Ensure that you have a bin folder there. If you don't find a bin it implies that you are in the wrong directory.

    Step 4: Now cd into the bin folder, and issue   $sudo -E ./Startup.sh , this command will start the tomcat server.

    -E gets the Java Environment.

    If you are prompted with a message as below, it concludes the proper start of the Tomcat.

    Using CATALINA_BASE:   /usr/share/tomcat7
    Using CATALINA_HOME:   /usr/share/tomcat7
    Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
    Using JRE_HOME:        /usr/lib/jvm/java
    Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
     
    If you are Prompted with  "JAVA_HOME or JRE_HOME not being defined" then you need to do
    $ sudo export JAVA_HOME=/usr/lib/jvm/java 

    Configuring Tomcat with Apache Solr

    Step 5: The actual integration of Apache Solr with Tomcat starts here.

    Managing Tomcat7 application

    sudo cp -R apache-solr/example/solr/ /usr/share/tomcat7/solr/
    sudo nano /etc/tomcat7/Catalina/localhost/solr.xml
    and paste
     
     
     
     
     

    Linking Drupal 7 with a running Apache Solr

    sudo cp apachesolr/schema.xml /usr/share/tomcat7/solr/conf/schema.xml

    sudo cp apachesolr/solrconfig.xml /usr/share/tomcat7/solr/conf/solrconfig.xml

    sudo cp apachesolr/elevate.xml /usr/share/tomcat7/solr/conf/elevate.xml


    Checking and Troubleshooting 


    Now set the port as 8080 in the apache Solr configuration page ie: http://knackforge.com:8080 and test the connection. If you are prompted with no errors, it implies the successful integration of tomcat with Solr.

    If not please check the permissions and to be in the best case use the below-mentioned one

    sudo chown -R tomcat7:root /usr/share/tomcat7/solr/ 

     

    Note: You can make use of this blog also with Drupal 6+, Apache Solr 1.3+ and Tomat 6+