Latest on twitter:
my projects and cool stuff
secretcities
website,
tagged posts
onefinestay
website,
tagged posts
me
twitter,
facebook
search
A quick and simple tutorial/guide. Its not particularly difficult but its always nice to have a clear reference. If you get into any troubles, get in contact and I’ll try sort you out/update the docs.
Install Java on Ubuntu 8.04 (Hardy Heron)
This should work for all newer versions of Ubuntu as well, but I’ve not tested it. As soon as the next supported release stands up I’ll whip out a brand spanking new tutorial.
So to get started, we need to add multiverse to the apt-get packages
# backup you're old settings file sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak; # this is a weird way of doing it but its incase you want to add this bit to a script sudo echo deb http:// us.archive.ubuntu.com/ubuntu/ hardy multiverse >> /etc/apt/sources.list; sudo echo deb-src http://us.archive.ubuntu.com/ubuntu/ hardy multiverse >> /etc/apt/sources.list; sudo echo deb http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse >> /etc/apt/sources.list; sudo echo deb-src http://us.archive.ubuntu.com/ubuntu/ hardy-updates multiverse >> /etc/apt/sources.list; sudo apt-get update;
Then once the packages are available to you, run the following in your console (NOT IN A SCRIPT). This will throw you into an install window, which you need to go through and accept the terms and conditions on.
sudo apt-get -y install sun-java6-jdk sun-java6-bin sun-java6-jre
Once thats over you’re done.
Install Tomcat 6.04
Next you’ll need Tomcat6. This is the apache server which will be running lucene where solr lives.
To do this get a stable core release from here. The package version I used is here. So just download the source and unzip (standard for mac, wget and tar for ubuntu). Then move it to a prime location. Personally I’m partial to /usr/lib/ but you can put it anywhere, just keep a note of where.
sudo wget http://mirror.lividpenguin.com/pub/apache/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz; sudo tar xvzf apache-tomcat-6.0.20.tar.gz; sudo mv apache-tomcat-6.0.20 /usr/lib/tomcat6; sudo rm apache-tomcat-6.0.20.tar.gz;
Then just check that “It works!”.
sudo /usr/lib/tomcat6/bin/startup.sh;
Hit http://localhost:8080/ and see if everything if alive and well.
Install Solr 1.5
This gets a little fiddly. First step is goto here and find the latest nightly build. I’m going to assume the version used was solr-yyyy-mm-dd.tgz and solr-1.5 but substitute as appropriate. Again I’m using /usr/lib/ to store the packages, so keep track if you install them anywhere else!
# make somewhere for it to go sudo mkdir /usr/lib/solr-1.5/; cd /usr/lib/solr-1.5/; # download sudo wget http://people.apache.org/builds/lucene/solr/nightly/solr-yyyy-mm-dd.tgz; sudo tar xvzf solr-yyyy-mm-dd.tgz;
We need to setup lucene (tomcat6) to act as the bundle operator.
# make the directory where solr is going to live sudo mkdir /usr/lib/tomcat6/data/; sudo mkdir /usr/lib/tomcat6/data/solr/; # copy the java plugin (solr package) into lucene cp /usr/lib/solr-1.5/apache-solr-1.5-dev/dist/apache-solr-1.5-dev.war /usr/lib/tomcat6/data/solr/;
Then we need to configure lucene to actually serve solr. To do this, create the file /usr/lib/tomcat6/conf/Catalina/localhost/solr.xml with the following contents.
<Context docBase="/usr/lib/tomcat6/data/solr/apache-solr-1.5-dev.war" debug="0" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/usr/lib/tomcat6/data/solr" override="true" /> </Context>
Next in the solr package you just downloaded, it contains a bunch of system example files. These will happily work in production and save you hours of time. So just copy them over.
sudo cp -R /usr/lib/solr-1.5/apache-solr-1.5-dev/example/solr/* /usr/lib/tomcat6/data/solr
At this point I recommend you make a backup of the setup. Just in case you corrupt the index somehow - you can just start afresh in an instant.
sudo cp -Rf /usr/lib/tomcat6/data/ /usr/lib/tomcat6/data.bak/
Now test it again. Restart tomcat6.
sudo /usr/lib/tomcat6/bin/shutdown.sh;
sudo /usr/lib/tomcat6/bin/startup.sh;
Hit http://localhost:8080/solr/ and see if its alive. If you go to http://localhost:8080/solr/admin there’s a nice console to have a play, check out the schema, stats etc…
Solango
If you are using django. I highly recommend django-solr-search it’s an incredibly flexible and robust wrapper.