Friday, May 27, 2011

Configuration and Installation of apache-solr and tomcat on your Drupal site

The Following are the steps which you will follow for the successful configuration of apache-solr and tomcat on your drupal site.

  • Download the apachsolr module from http://drupal.org/project/apachesolr and place it in your modules folder. In my case I placed it in sites/all/modules/apachesolr.
  • Download the SolrPhpClient from http://code.google.com/p/solr-php-client/downloads/list and placed inside the apachesolr module. In my case I placed it in sites/all/modules/apachesolr/SolrPhpClient.
  • Enable the Apache Solr Framework and Apache Solr Search modules.
  • Download the apache-solr from http://mirror-cybernet.lums.edu.pk/pub/apache//lucene/solr/1.4.1/ and place it any where you want but outside from your drupal site. In my case I placed it in C:\apache-solr-1.4.1.
  • Download the apache tomcat from http://tomcat.apache.org/download-70.cgi and extract it to the folder of your liking. In my case I placed it in C:\apache-tomcat-7.0.14.
  • Download the jdk from http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-download-346242.html and install it.
  • Rename the schema.xml, solrconfig.xml and protwords.xml to schema.bak, solrconfig.bak and protwords.bak respectively in apache-solr\example\solr\conf folder. In my case C:\apache-solr-1.4.1\example\solr\conf.
  • Copy the schema.xml, solrconfig.xml and protwords.xml from the apachesolr module folder and paste it in the apache-solr\example\solr\conf folder. In my case I copied the files form sites\all\modules\apachesolr and pasted in C:\apache-solr-1.4.1\example\solr\conf.
  • Copy the apache-solr-1.4.1.war from apache-solr\dist and paste it in apache-tomcat\webapps folder and rename it to solr.war. In my case I copied the file from the C:\apache-solr-1.4.1\dist and pasted it inside the C:\apache-tomcat-7.0.14\webapps and renamed it to solr.war.
  • Set the JAVA_HOME environmental variable by running the command “set JAVA_HOME=path/to/your/jdk”. In my case I ran the command “set JAVA_HOME= C:\program files\java\jdk1.6.0”.
  • Open the command prompt and go to the folder of apache-tomcat/bin and type startup and press enter to start the tomcat.


    Then type the shutdown and press enter to stop the apache-tomcat.


  • This will unpack the war file resulting in the folder apache-tomcat/webapps/solr. In my case C:\apache-tomcat-7.0.14\webapps\solr.
  • Open the web.xml file from apache-tomcat\webapps\solr\WEB-INF and uncomment the section specifying the solr/home environment variable and set its value to the path of your apache-solr example application folder. In my case I opened the file from C:\apache-tomcat-7.0.14\webapps\solr\WEB-INF and did the following changes.


    solr/home
    C:/apache-solr-1.4.1/example/solr
    java.lang.String


  • Open the commands prompt and go to the folder apache-solr/example and type “java –jar start.jar” and press enter to run the jdk. In my case look at the following image.

  • Now start the apache-tomcat as defined above in this document.
  • You can access the solr administration interface now at http://localhost:8080/solr/admin/.
  • Go to the path admin/settings/apachesolr of your drupal site and enable the make apache solr search the default under the advance configuration.
  • The synonyms.txt file is in apache-solr/example/solr/conf folder. In my case C:\apache-solr-1.4.1\example\solr\conf. Open the file and enter some words just like Television and TV and save the file.
  • Then go to your drupal site and run the cron to send the contents form your drupal site to the apache-solr search.
  • Then restart the jdk so that changes to the synonyms.txt file take affects.
  • Then search for those specific terms you will see the results.

    Note: Remember to run the cron every time you add some contents to your drupal site so that it makes searchable for apache-solr search.
    Now your site is ready for apache-solr search. If you get some errors or your search does not work then follow these steps carefully may be you have missed a step.
  • 1 comment: