Tomcat 7 & Multi Core Apache Solr 4.7 installation and configuration with Drupal 7 on Ubuntu 12.04

Tomcat 7 & Multi Core Apache Solr 4.7 installation and configuration with Drupal 7 on Ubuntu 12.04

Apache Solr is a proven and popular open source search platform developed by Apache Lucene. It is an application developed in java and runs as a standalone full text search server embedded in a servlet container. Solr search is server-independent and supports the following features:

Multi Site Search: Multiple search sites can be performed when the large number of websites have a common index. The shared index of these sites stores the documents with a site and a hash field which enables to filter by keywords and generate the results either from a single site or the sites that share the index. There is Apache Solr Multisite Search Module  which adds the tab "Multisite search" to the search page.

Distributed Search: Takes place either when the length of the index exceeds the capacity of a single system or when the execution of a query takes a long time and splits the data into different parts. Solr can query and join the split results.

Faceted Search: This technique is used to minimize the search result according to the categories and get the relevant information. The end users are able to extract adequate information in several ways to meet their needs e.g. in a retail website, when a product is searched, the users get additional options to narrow search result in the left hand side. These options make the search more accurate and specific.

Solr also has an edge over drupal core search with respect to indexing and scalability.

Java Installation
Tomcat and Solr are dependent on Java Development Kit(JDK) and run on Java Virtual Machine (JVM). JDK consists of JVM and Java Runtime Environment (JRE). Therefore, we need to install full JDK.

aptitude install java7-jdk 

Tomcat 7
Apache Tomcat is another open source web server consisting servlet container. It enables us to view and run jsp and servlets in the browser. Apache Tomcat consists of configuration and management tools. However, it can be configured by editing XML configuration files. Tomcat 7 runs on Servlet 3.0 and JSP 2.2 specification. It requires Java Development Kit (JDK 1.6) and later version.

Installing Tomcat 7

  1. Add a user and associated permission
    useradd -Mb /usr/local tomcat
    chown -R tomcat:tomcat /usr/local/tomcat
  2. Get the Tomcat’s latest version from and download the file tar.gz binary to usr/local/src server and extract the file to usr/local/tomcat
    tar -C /usr/local -zxf /usr/local/src/apache-tomcat-7.*.tar.gz 
    mv /usr/local/apache-tomcat-7.* /usr/local/tomcat
  3. The default HTTP connector port and AJP connector port is 8080 and 8009 respectively. We had varnish installed on port 80 & Apache running on 8080. To avoid, we have to change port number Tomcat listens to. Command line to find & replace port number -
    sed -i s/8080/8983/g /usr/local/tomcat/conf/server.xml
    // You can give any non conflicting port number
  4. Test the successful installation of Apache Tomcat
    sudo -u tomcat /usr/local/tomcat/bin/

You are good to go if you don’t see any errors on your termial.

Solr Installation steps

  1. Download Solr 4.7 from and extract the downloaded file
    cd /usr/local/src
    tar -zxf solr-4.7.2.tgz
  2. Copy the Solr java library files from Solr to Tomcat library directory
    cp solr-4.7.2/dist/solrj-lib/* /usr/local/tomcat/lib/
  3. Copy log4j configuration file from Solr to Tomcat config directory
    cp solr-4.7.2/example/resources/ /usr/local/tomcat/conf/ 
  4. Install Apache Solr’s war into Tomcat Webapps directory
    cp solr-4.7.2/dist/solr-4.7.0.war /usr/local/tomcat/webapps/solr.war
  5. Add Solr context file in /usr/local/tomcat/conf/Catalina/localhost/solr.xml and add the following code

Solr Configuration with Drupal

  1. Create the Solr directory and copy the example Solr configuration
    mkdir -p /usr/local/tomcat/solr
    cp -r solr-4.7.2/example/solr/collection1/conf /usr/local/tomcat/solr/
  2. Get the latest version of Search API Solr Search from Drupal ( Apache Solr Drupal module didn’t worked with Solr 4.7.2 though it used to work with Solr 4.4 )
    cd /usr/local/src
    tar -zxf search_api_solr-*.tar.gz
  3. Copy Solr configuration files from Search API Solr Searchl module to Tomcat configuration directory
    rsync -av search_api_solr/solr-conf/4.x/ /usr/local/tomcat/solr/conf/
  4. Create Apache Solr Drupal setting in the path /usr/local/tomcat/solr/solr.xml and paste the following to define valuebound core (you can have own name for the core)
  5. Make valuebound Solr core directory and copy Solr configuration files to new core
    mkdir /usr/local/tomcat/solr/valuebound
    cp -r /usr/local/tomcat/solr/conf /usr/local/tomcat/solr/valuebound/
  6. Now just stop tomcat and assign the permission and check this
    chown -R tomcat:tomcat /usr/local/tomcat
    sudo -u tomcat /usr/local/tomcat/bin/

Now you will test your new the valuebound Solr core admin interface in But you should be using URL while configuring Drupal Apache Solr.

Now to start tomcat automatically every time you restart server -

Download this tomcat init script. Create init file for tomcat at /etc/init.d/tomcat and copy paste content of tomcat.txt.

vi /etc/init.d/tomcat



Valuebound is a Drupal development company providing Apache Solr Implementation and integration with Drupal CMF. Contact us if you would like to use Apache Solr to improve search result for your Drupal driven web sites and applications..