Apache Solr 4.0 with Apache Tomcat 7 in Ubuntu Linux

If you want to configure Solr4.0.0 in Windows environment please click here.
In this blog i will tell you how to integrate Solr4.0 with apache-tomcat 7 in linux environment. Before we start i recommend you to read an Introduction of solr4.0 from here.

Pre Requirements
1 ? Machine with Linux (Ubuntu, fedora ..etc)
2 ? Java 6 or Above
3 - Solr 4.0.0 or Above
4 ? Apache-tomcat 7 or Above.

Steps to get Solr up on Tomcat Server
  • Install Tomcat on your machine and and make sure it is ready to start.
  • Install Solr4.0 distribution package apache-solr-4.0.0.tgz and unzip it in your local directory like /home/javaguys/apache-solr-4.0.0.
  • Make a folder with name solr-home in your local machine like /home/javaguys/solr-home.
  • Go back to the solr distribution package that you downloaded /home/javaguys/apache-solr-4.0.0. Have a peek inside the Examples folder. Copy all those files into the /home/javaguys/solr-home folder.
  • Look into /home/javaguys/solr-home/solr and you will see two folders with name collection1 and bin, copy these two folders a step up to /home/javaguys/solr-home.
  • Look into /home/javaguys/apache-solr-4.0.0/contrib/extraction in downloaded solr package and you will get a lib folder here , copy this folder to /home/javaguys/solr-home.
  • Go to /home/javaguys/apache-solr-4.0.0/dist and copy apache-solr-dataimporthandler-extras-4.0.0.jar, apache-solr-dataimporthandler-4.0.0.jar and apache-solr-cell-4.0.0.jar to home/javaguys/solr-home/lib
  • Create a file with name data-conf.xml  in /home/javaguys/solr-home/collection1/conf and add your database details to it like


Add this file entry to /home/javaguys/solr-home/collection1/conf/solr-config.xml file like


Copy apache-solr-4.0.war from /home/javaguys/apache-solr-4.0.0/dist directory to webapps directory inside Tomcat.
Start your Tomcat and check webapps directory having one new directory added with name solr.
Look inside /home/javaguys/apache-tomcat-6.0.36/webapps/solr/WEB-INF and open web.xml in a text editor, now look for an entry like this
<!-- <env-entry>
<env-entry-value> /Path/To/My/solr/Home/solr/</env-entry-value>
</env-entry> -->
uncomment the entry and add your solr-home path /home/javaguys/solr-home to value tag.
  • Add your new libraries location to /home/javaguys/solr-home/collection1/conf/solr-config.xml.  just under <config>  tag like <lib dir="/home/javaguys/solr-home/lib" />.
And you are all done with it , start your server to localhost:8080/solr and you will get your solr admin panel up.

In upcoming blogs we will see how to make queries to solr server and other important stuff with solr 4.0.0.