Drupal coder

Installing Apache Solr in Tomcat for Drupal on Snow Leopard

There's quite a few information available on how to install Apache Solr for your Drupal website. One of the best places to start is the Apache Solr Search Integration module documentation page. In this post I will gather all the bits and pieces for installing Solr in Tomcat on one specific platform: Snow Leopard. This is the platform I'm developing Drupal sites on and the great thing is it has all the needed Java stuff built in, so it's quite easy to install Solr and Tomcat. This method might work on some other systems too having Java 1.6 (with mostly some minor adjustments) but I've not tested this.

Install guide

  • Download and install the Apache Solr Search Integration module.
  • Download the Apache Solr PHP Client. As of the module requires revision 22.
    Extract this package and move the resulting folder to the module folder. You will now have something like [YOUR-MODULES-FOLDER]/apachesolr/SolrPhpClient/Apache/Solr/Service.php.
  • Download Apache Solr. You might find a faster and newer version for your location on the downloads overview page.
    Extract this package and move it to a folder of your liking. I'm using ~/bin/apache-solr-1.4.0.
  • Copy solrconfig.xml and schema.xml from the module folder to the Solr instance configuration folder. In my case this is in ~/bin/apache-solr-1.4.0/example/solr/conf. You might want to rename the schema and config file in that folder first to keep a backup.
  • Download the core binary distribution of Apache Tomcat 6 (direct link for 6.0.24).
    Extract this package and move it to a folder of your liking. I'm using ~/bin/apache-tomcat-6.0.24.
  • Copy the Solr web application~/bin/apache-solr-1.4.0/dist/apache-solr-1.4.0.war to your Tomcat webapps folder and rename it to solr.war. In my case this resulted in ~/bin/apache-tomcat-6.0.24/webapps/solr.war.
  • Start and immediately shutdown Tomcat by running the following in your terminal (from your home folder):
    ~/bin/apache-tomcat-6.0.24/bin/startup.sh
    ~/bin/apache-tomcat-6.0.24/bin/shutdown.sh
    

    Note that the exact Tomcat folder name might depend on the Tomcat version you downloaded..
    This will unpack the war file resulting in a folder ~/bin/apache-tomcat-6.0.24/webapps/solr/.

  • We now just have to point the Solr web application in Tomcat to the Solr example application. You can do this by adjusting the web application configuration file (WEB-INF/web.xml). Uncomment the section specifying the solr/home environment variable and set its value to the path of your Solr example application folder.

    In my case the configuration file was located at ~/bin/apache-tomcat-6.0.24/webapps/solr/WEB-INF/web.xml and after replacing the solr/home section I had.
    <env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>~/bin/apache-solr-1.4.0/example/solr</env-entry-value>
       <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
    
  • Your system is now set up and you can start Tomcat now issueing the following command in your terminal.
    ~/bin/apache-tomcat-6.0.24/bin/startup.sh
    
  • You can access the Solr admininstration interface now at http://localhost:8080/solr/admin/.
February 15, 2010Apache Solr, Drupal, OS X, search, Tomcat

Comments

Raviish,

I'm guessing that you downloaded the same distribution of solr that I did. Check that the path you are trying to use exists. My uncompressed solr 3.5 has the example here:

apache-solr-3.5.0/solr/example/solr

Unless of course you pulled the example out of the distribution folder and created another apache-solr-3.5.0 folder in bin.

Hope this helps,
Jack

Thank you for sharing this install/setup. It worked perfectly for me on OS X 10.6.8. I appreciate that you took the time to put this together and post it.

Nice post !
but it my case it still didn't work
error was the
HTTP ERROR: 404 missing core name in path
I couldn't get why it started to work when I changed path:
from
~/bin/apache-solr-3.5.0/example/solr
to
/bin/apache-solr-3.5.0/example/solr/

and then I again changed path to
~/bin/apache-solr-3.5.0/example/solr/

and it kept on working.
well I will try and figure out this later but I will come back to it.

If ny1 knows why please do let me..

CHeer!
Raviish

Someone asked for a guide on windows.

I installed solr several times using this guide
http://wiki.apache.org/solr/SolrTomcat

untill I needed to do one via plesk :-0 Then I needed this guide to remind me to have a solr.xml

Thank you
drupalcoder

solr/lucene are about indexing and searching.

This covers search only.

How do you setup indexing in tomcat?

I installed Solr for windows but haved an error, Can you help me how to install windows on it?
Thanks a lot

SearchBlox is another tool that can be used for searching drupal sites. SearchBlox is also based on Lucene similar to Solr.

Thanks a lot. It is really helpful and thanks for saving so much of my time...

Thanks for this! These are the only instructions out there that were able to get me up and running on tomcat/centos with ease.

Thank you -- the WEB-INF/web.xml change was non-obvious IMHO and I spent several hours looking at the rather inadequate Solr docs and trying to figure out why my install didn't work. Your walkthrough really helped!

I write almost the same guide bug without tomcat: http://listentothis.net/drupal/installing-apache-solr-mac-osx-snow-leopa...

Hi,

I was having the same message as above about not being able to locate the solrconfig.xml until I realized that the
solr/home

was commented out (with a my tomcat WEB-INF/web.xml !
I

If you're greeted by a 500 error and the message "Can't find resource 'solrconfig.xml'" when directing your browser to localhost:8080/solr/admin, try using the following directives instead of the ones above for your solr/home secion in web.xml:

solr/home
/Users/yourusername/bin/apache-solr-1.4.0/example/solr
java.lang.String

Hmmm. It's stripped my triangular brackets out, but you get my drift :P

Excellent post! Thank you very much!

I found that the final bit of code didn't recognise ~/ as the home directory, I had to use the absolute path to get it to work.

solr/home
/Users/username/bin/apache-solr-1.4.0/example/solr
java.lang.String

Cheers, Ben

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options