Installing Apache Tomcat 6 and Solr nightly on Ubuntu 8.04
Getting Solr to play nice with Tomcat on Ubuntu was an interesting journey, I almost gave up entirely at one point. I'm compiling this how-to from tips I got from multiple websites. I'll try to make as complete a list as I can remember at the end of this post.
First off, forget about using the Ubuntu packages of Tomcat and Solr, they're broken, as well as outdated. Download the latest release of Tomcat from their site, and grab a nightly build of Solr from here using wget or whatever method you prefer. Untar both of them in your home directory.
tar xfzv apache-tomcat-6.0.18.tar.gz
tar xfzv solr-2009-04-06.tgzNow, move Tomcat to wherever you want to have it installed, I chose to put it in /usr/local/tomcat6.
sudo mv apache-tomcat-6.0.18/ /usr/local/tomcat6/Next, copy the Solr .war file from apache-solr-nightly/dist/ to the webapps/ directory of tomcat6/, and the example webapp from apache-solr-nightly/example/solr/ to the tomcat6/ root directory.
sudo cp apache-solr-nightly/dist/apache-solr-nightly.war /usr/local/tomcat6/webapps/solr.war
sudo cp -r apache-solr-nightly/example/solr/ /usr/local/tomcat6/solr/Now that all the files are in place, we need to create a config file to run Solr.
sudo mkdir /usr/local/tomcat6/conf/Catalina/
sudo mkdir /usr/local/tomcat6/conf/Catalina/localhost/
sudo nano /usr/local/tomcat6/conf/Catalina/localhost/solr.xmlIn this file, insert the following code:
<Context docBase="/usr/local/tomcat6/webapps/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/usr/local/tomcat6/solr" override="true" />
</Context>Edit your .bashrc file in your home directory and add the following to it:
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/local/tomcat6/solr"If all went well, you should be able to start Tomcat and browse to http://your.servers.ip:8080/solr/admin and see the Solr admin page.
/usr/local/tomcat6/bin/startup.shIf this worked, great, but now it's time to get Tomcat to autostart itself when your server reboots. First, open a new script in your /etc/init.d/ directory.
sudo nano /etc/init.d/tomcat6Insert the following code:
# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/local/tomcat6/solr"
case $1 in
start)
sh /usr/local/tomcat6/bin/startup.sh
;;
stop)
sh /usr/local/tomcat6/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat6/bin/shutdown.sh
sh /usr/local/tomcat6/bin/startup.sh
;;
esac
exit 0Finally, to make sure it autostarts, run this command:
sudo update-rc.d tomcat6 start 91 2 3 4 5 . stop 20 0 1 6 .Congratulations! If you've followed this how-to exactly, you should have a working install of Apache Tomcat and Solr.
Links I got tips from:
http://wiki.apache.org/solr/SolrTomcat
http://www.tc.umn.edu/~brams006/solr_ubuntu.html
http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/
http://lethain.com/entry/2009/mar/06/solango-and-tomcat-6-on-ubuntu-intrepid/
http://markmail.org/message/2xxiyry4y42hpodd
http://ubuntuforums.org/showthread.php?t=194559
And another for those wishing to receive training in administering Apache Tomcat:
http://marakana.com/training/tomcat/apache_tomcat_administration.html
Comments
May 13, 2009 at 5:17pm
Thanks for the walkthrough. I've been having trouble getting Solr to work on Tomcat too. Consistent and up-to-date information has been hard to find. Think my problem was that I was using a 5.X version of Tomcat - works fine now with 6.x. Cheers.
May 13, 2009 at 7:12pm
You're right, the documentation out there is very inconsistent, out-of-date, and incomplete. Glad I was able to help.
June 12, 2009 at 10:51am
This is a very useful walkthrough, but I seem to be getting caught after having edited .bashrc; when trying to access the Solr admin page, I see the following:
HTTP Status 404 - /solr/admin
type Status report
message /solr/admin
description The requested resource (/solr/admin) is not available.
Apache Tomcat/5.5
Any advice you could offer would be greatly appreciated.
June 12, 2009 at 12:14pm
I can't guarantee that my guide will work if you're using Tomcat 5.5. I'd recommend you switch to 6.
June 12, 2009 at 2:23pm
What is the best way to go about doing this? I tried going through the installation of Tomcat 6 as you described it, but as you can see, Tomcat 5.5 was not overwritten - am I missing a step?
June 12, 2009 at 6:32pm
The best thing to do would be to delete everything you installed and downloaded and start from scratch, in that case.
December 23, 2009 at 3:29pm
Thanks a million! Great tutorial. Works perfect for Ubuntu 9.10.
NOTE TO OTHERS: I had to chmod 755 /etc/init.d/tomcat6 to get it to be executable. Then tomcat will survive a reboot.
February 24, 2010 at 6:44am
Thanks. Works Perfectly.
April 2, 2010 at 1:29pm
Hey Justin,
thanks for the tutorial, I have a question, my solr is installed on the folder /solr and when I try to go to the mydomain.com:8080/sorl/admin it gives me:
message: missing core name in path.
I'm running this on my server so should I change "localhost" to my domain "mydomain.com"?
Tomcat6, Java1.6
Post new comment