Installing Apache Solr 4.7 multicore on Ubuntu 12.04 and Tomcat7



Case type:

Service area: 


I will show you how to install the ApacheSolr search engine under Tomcat7 servlet container on Ubuntu 12.04.4 LTS (Precise Pangolin) to be used later with Drupal 7. In this writeup I'm gonna discuss only the installation and setup of the ApacheSolr server. Specific Drupal configuration and/or Drupal side configuration to be discussed in future writeup.


We’re installing Oracle Java 7 before installing Tomcat7:

$ sudo apt-get purge oracle-java6-installer
$ sudo apt-get install software-properties-common python-software-properties
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer

Then get Tomcat7:

$ sudo apt-get install tomcat7 tomcat7-admin

Solr 4.7

$ cd ~
$ curl > solr-4.7.0.tgz
$ tar xzvf solr-4.7.0.tgz
$ sudo mv solr-4.7.0 /usr/share/solr
$ cd /usr/share/solr/example
$ sudo cp webapps/solr.war multicore/solr.war
$ cd /usr/share
$ sudo cp -r solr/example/lib/ext/* tomcat7/lib/
$ sudo cp -r solr/example/resources/ tomcat7/lib/


Edit and set the solr.log setting:

$ sudo nano /usr/share/tomcat7/lib/

Set there solr.log=/usr/share/solr.

Now, let’s a get Solr into Tomcat Catalina config. Create a new solr.xml file:

$ sudo nano /etc/tomcat7/Catalina/localhost/solr.xml

and add

<Context docBase="/usr/share/solr/example/multicore/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr/example/multicore" override="true" />

Add Tomcat GUI administrative users:

$ sudo nano /etc/tomcat7/tomcat-users.xml

Add the tomcat user within the block:

  <role rolename="manager-gui"/>
  <user username="admin" password="mysecretpassword" roles="manager-gui"/>

Ensure correct permissions:

$ sudo chown -R tomcat7 /usr/share/solr/example/multicore

Restart Tomcat:

$ sudo service tomcat7 restart


You are able now to access the Solr administrative interface at http://localhost:8080/solr.

Apache Solr services, corresponding to each configured core are delivered at:

  • http://localhost:8080/solr/core0
  • http://localhost:8080/solr/core1


Place the next line inside <Context> in /etc/tomcat7/Catalina/localhost/solr.xml:

<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="|" />

You're done. Now it's time to configure Solr and you application that use it. About that in another writeup.