I'm having difficulties installing Apache Solr. The latest version that I downloaded was 4.6.0. But all Drupal documentation and tutorials (see http://www.youtube.com/watch?v=ori-VvvH1Aw) are talking about 3.5.0. While 3.5.0 is nowhere to be found on internet, 4.6.0 has a totally different directory structure, and there is no documentation on how to install this latest version on a server or on a local WAMP. There is no mentioning of which Apache Solr versions are most recommended to work with Drupal? Any help?


4 Answers 4


You aren't alone I had to scour the internet and read several articles before I truly understand all of this. I tried about three different methods until I finally got it right!

If you are using Debian/Ubuntu (with Tomcat7) it's even easier then most outline. I preferred this over Lullabot since when you install it through Ubuntu it's actually a service and less fiddling :)

Install Java

apt-get install java7-jdk

Install Tomcat

apt-get install tomcat7 tomcat7-admin

Once this is done you can get to http://localhost:8080 and see that's it is all running properly.

Note: It's recommended to push the port to another one since 8080 is pretty common. If you want to do that use this code for that!

sudo sed -i s/8080/8983/g /var/lib/tomcat7/conf/server.xml

Configure Tomcat

  1. You will want to actually create a users account for Tomcat so that other people have to log into the admin (it keeps it safer).

    nano /var/lib/tomcat7/conf/tomcat-users.xml

  2. Then add these xml arguments between the <tomcat-users> tags

    <role rolename="manager-gui"/> <role rolename="admin-gui"/> <user username="!!somename!!" password="!!somepassword!!" roles="manager-gui,admin-gui"/>

  3. Now you can restart tomcat again and view the admin page at http://localhost:8983/manager/html

    service tomcat7 restart

Install Solr

  1. Download the latest ApacheSolr here (When I wrote this I got it working with 4.7)

  2. Extract the files into a directory

Copy Solr library files

Next we want to add the library files to Tomcat library directory. Note: You can also use symlinks if you prefer, but for the purpose of understand where everything goes I chose to place it directly in the directories

cp ~/solr-4.x.x/example/lib/ext/* /usr/share/tomcat7/lib/

It may be a good idea to also copy the java libraries from solr/dist/solrrj-lib/*

cp ~/solr-4.x.x/dist/solrj-lib/* /usr/local/tomcat7/lib/

Copy Solr WAR app file

cp ~/solr-4.x.x/dist/solr-4.x.x.war /var/lib/tomcat7/webapps/solr.war

Setup Drupal ApacheSolr core

  1. We first need to copy over the sample configuration files from ApacheSolr.

    mkdir -p /var/lib/tomcat7/solr cp -r ~/solr-4.x.x/example/solr/collection1/conf /var/lib/tomcat7/solr/

  2. Next grab the latest version of the apachesolr module https://drupal.org/project/apachesolr and unzip it

    tar xvf apachesolr-*.tar.gz

  3. Syncronize the apachesolr configuration files (for Drupal) with your solr configuration

    rsync -av apachesolr/solr-conf/solr-4.x/ /var/lib/tomcat7/solr/conf/

Note: I found an error in which ApacheSolr refused to start due to duplicate errors. I reported that here so you might want to look at the solution here as at the time of writing this I could not get it running without that!

  1. Create a core definition file to tell Apache Solr which cores are available.

    nano /var/lib/tomcat7/solr/solr.xml

  2. Paste the following code inside that file

    <?xml version="1.0" encoding="UTF-8" ?> <solr persistent="false"> <cores adminPath="/admin/cores"> <core name="!!yourcorename!!" instanceDir="!!yourcoredir!!" /> </cores> </solr>

Create Drupal core directory

This will create a new core in your system with that name. If you wish to add more you simply can repeat this step as well as the one above.

mkdir /var/lib/tomcat7/solr/!!yourcoredir!!
cp -r /var/lib/tomcat7/solr/conf /var/lib/tomcat7/solr/!!yourcoredir!!/

Let's Make It Live

  1. Your at the last stretch!! Let's put tomcat7 to sleep

    service tomcat7 stop

  2. Now change the permissions on the tomcat directory

    chown -R tomcat7:tomcat7 /var/lib/tomcat7

  3. Start it back up

    service tomcat7 start

It's Live

You should be able to go to http://localhost:8983/solr and see a new core instance available! Now you can go ahead and configure drupal to point to that.

Note: Your new core is located at http://localhost:8983/solr/!!yourcorename!! to be used in the Drupal ApacheSolr module.

Credit and props goes out to Pacoup

  • 1
    Great guide. Under "configure Tomcat" it is missing the xml under step 2: "Then add these xml arguments between the tags"... no xml given. Oct 21, 2014 at 18:27
  • Hmm it's there but you can't see it maybe cause of your browser? Let me try and change the output to fix that Oct 23, 2014 at 16:17
  • Actually I just checked and I am using the proper code tags? Oct 23, 2014 at 16:19
  • See screenshot: i.imgur.com/s1jlunf.png Oct 24, 2014 at 18:46
  • I fixed it. xml code needs to be placed between ` ` Oct 24, 2014 at 21:32

Changes to Solr 4 have been discussed in the issue queue: https://drupal.org/node/1676224

The issue contains a number of links to sandbox sites and tutorials.


Here is how it's described in Drupal Community Documentation (Installing Solr on Tomcat):


This walk-through assumes you already have Tomcat installed. If you don't it is probably easier to just use WHM and install it there and rebuild apache. Point and click is what I say.

Once you have Tomcat installed you can verify its installation by going to:


You should see the default Tomcat page. If not, ask someone for help. If you don't, you are hurting the next person who comes along with the same issue. If we didn't want to help we wouldn't be Open Source.

Download your a copy of Solr. If you don't know where to get it, google it.

To make things easier now and in the future, find your Tomcat installation

$ locate tomcat

Create a soft link like so:

ln -s /my/tomcat/location /tomcat

If you did it right you should be able to just

$ /tomcat

in sshd and get to your directory.

I will be using the /lib directory for my example. If you don't have one, create it with mkdir /lib command.

  1. Extract Solr to temporary location, for my sake, I just get the zip file from Solr mirrors.

    $ unzip apache-solr-1.4.1.zip /lib/

    Build your Solr

    $ cd /lib/solr
    $ ant dist (you should see it building something.)
  2. Rename your war file for ease of use.

    $ cd /lib/apache-solr-1.4.1
    $ cd dist
    $ mv apache-solr-1.4.1.war solr.war  (this just renames it without asking you)
    $ dir  (check to make sure it worked. you should see solr.war)
  3. Copy solr.war to /lib/solr/example

    $ cp solr.war /lib/solr/example
    $ cd /lib/solr/example
    $ dir  (verify that the solr.war is in the directory, you should also see the familiar start.jar file there)
  4. Copy the xml files from your apachesolr location. Usually it will be:

    $ cp /home/YOUR_NAME/www/modules/apachesolr/*.xml /lib/solr/example/solr/conf</code>
  5. Create an xml file in Tomcat to tell it to run Solr at Tomcat start-up

    $ cd /tomcat
    $ cd /conf/Catalina/localhost
    $ vi solr.xml

    Paste this into your new file:

    <?xml version="1.0" encoding="utf-8"?>
    <Context docBase="/solr/example/solr.war" debug="0" crossContext="true" >
       <Environment name="solr/home" type="java.lang.String" value="/solr/example/solr" override="true" /> 

    The two values you should be customizing are Context::docBase (to point to your .war file) and Environment::value (to point to your solr directory). Note that in this example the .war file is in the solr directory, which is a fine pattern to follow.

    {Press Escape and then :w} and then {Press Escape Key and then :q}

  6. Restart Tomcat using WHM for ease. It's under Restart Services. Then go here:


    You may get this error:

    false in null ------------------------------------------------------------- java.lang.RuntimeException: java.io.IOException: Cannot create directory: /usr/share/solr/data/index at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:398) at org.apache.solr.core.SolrCore.(SolrCore.java:546) at ...

    Don't panic. I gatcha!

    Go to solrconfig.xml again

    $ cd /solr/example/solr/conf
    $ vi solrconfig.xml

    and modify this line:




    Restart Tomcat again and go here:



    Go to your schema.xml file in /lib/solr/example/solr/conf:

    $ vi schema.xml

    Add this in the section just after <field>:

      <field dest="host" source="host"/>
      <field dest="segment" source="segment"/>
      <field dest="boost" source="boost"/>
      <field dest="digest" source="digest"/>
      <field dest="tstamp" source="tstamp"/>

    Save it and exit {Press Escape Button) :w (Press Enter) then (Press Escape Button) :q (Press Enter)

    If you are using Nutch then go here and install/configure nutch.

For Apachesolr in Drupal 6.x, see: Setup Drupal 6.x with Apache Solr on Tomcat6 and Ubuntu.


All solr version should work with Drupal as long you've module which supports it.

For example Apachesolr module, has configuration files for: Solr: 3.x and 4.x.

For Search API Solr Search module, you can find the configuration files for Solr: 3.x, 4.x and 5.x, so it shouldn't be a problem.

How to install Solr, it's another thing. There are many ways of doing it. Few examples below.



Simplest way is to install latest Apache Solr using Homebrew, e.g.:

brew install solr
ln -sfv /usr/local/opt/solr/*.plist ~/Library/LaunchAgents
brew services start solr # Or just: solr start

Now installed Solr instance is accessible at: http://localhost:8983/


Simplest way is to install Solr via apt:

sudo apt-get install solr-tomcat

via Puppet

Use Puppet manifest to install Solr. Here is one solr4-tomcat.pp example.

Manually (4.x or 5.x)

$ VER=4.10.4 # Solr version.
$ TOMCAT_BASE=/var/lib/tomcat7
$ sudo apt-get install tomcat7 tomcat7-admin
$ sudo sed -i.org 's|port=\"8080\"|port=\"8983\"|g' /etc/tomcat?/server.xml
$ sudo mkdir -p /opt/solr/home/collection1/conf /opt/solr/data
$ cd /opt/solr
$ curl -s http://archive.apache.org/dist/lucene/solr/$VER/solr-$VER.tgz | sudo tar zxvf -
$ sudo cp -v /opt/solr/solr-$VER/dist/solr-$VER.war $TOMCAT_BASE/webapps/solr.war
$ sudo cp -v /opt/solr/solr-$VER/example/lib/ext/*.jar /opt/solr/solr-$VER/dist/solrj-lib/*.jar /opt/solr/solr-$VER/example/resources/log4j.properties $TOMCAT_BASE/webapps/solr/WEB-INF/lib
$ curl -s http://ftp.drupal.org/files/projects/search_api_solr-7.x-1.x-dev.tar.gz | sudo tar zxvf -
$ sudo cp -v search_api_solr/solr-conf/4.x/* home/collection1/conf/
$ sudo /etc/init.d/tomcat7 restart

Check if it is working at: http://localhost:8983

See also:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.