Archive for August, 2009

Installing Solr nightly on Ubuntu 9.04

Saturday, August 15th, 2009

Note: this is adapted from http://justin-hayes.com/2009-04-08/installing-apache-tomcat-6-and-solr-nightly-on-ubuntu-804.

Install Java 6 JDK:

sudo apt-get install sun-java6-jdk

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.

wget http://www.eng.lsu.edu/mirrors/apache/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz

tar xfzv apache-tomcat-6.0.20.tar.gz
wget http://people.apache.org/builds/lucene/solr/nightly/solr-2009-08-11.tgz
tar xfzv solr-2009-08-11.tgz

Now, 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.20/ /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.xml

In 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.sh

If 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/tomcat6

Insert 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 0

Finally, 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