Blacklight, Solr, Ruby and Rails on Ubuntu

The BRUCE project is using Apache Solr and Project Blacklight as its core technologies and at least some of the development is going on on Ubuntu. The Blacklight Ubuntu install has a couple of gotchas which aren’t covered by the standard Blacklight documentatio0n and aren’t so well serviced by all of the Rails on Ubuntu blog posts that we read. So here is a very short write up of an approach to Blacklight, Solr, Ruby and Rails on Ubuntu:

First, Some Useful Links

The Blacklight README

The Blacklight Pre-Requisites

How-To for Ruby 1.8 on Ubuntu

Install Ruby

The following commands install everything you need to run ruby (it’s more than is required just for Blacklight):

sudo aptitude install build-essential zlib1g zlib1g-dev libxml2 libxml2-dev libxslt-dev

sudo aptitude install sqlite3 libsqlite3-dev locate git-core libmagick9-dev

sudo aptitude install curl wget

sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8

sudo aptitude install libruby1.8 libopenssl-ruby rubygems1.8

Ruby does not put everything on the system PATH so, set the following symlinks:

sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc

sudo ln -s /usr/bin/irb1.8 /usr/bin/irb

sudo ln -s /usr/bin/ri1.8 /usr/bin/ri

sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem

Install Java

Solr depends on java, so if you don’t have a JDK installed already we need to get one of those

sudo aptitude install openjdk-6-jdk

Add some new Ruby Gems sources

We need to add a couple of sites where gem will get the ruby gems from. These are the most useful ones, which will cover us for this install.

gem sources -a http://gems.github.com

gem sources -a http://gems.rubyonrails.org

gem sources -a http://gemcutter.org

Install the required Gems (including Rails)

Now we use gem to install the rest of the ruby dependencies for Blacklight. NOTE that we DO NOT install Rails using aptitude. This would be a disaster and nightmare rolled into one.

sudo gem install rubygems-update

sudo gem install rake nokogiri hpricot builder cheat daemons

sudo gem install json uuid rmagick sqlite3 fastthread rack

Finally install the specific version of rails recommended by the Blacklight documentation. NOTE that this command can take a while to initialise, but it will get there in the end, just be patient.

sudo gem install -v=2.3.11 rails

Put relevant Gems on the PATH

On Ubunutu, the gem installer does not place your executables on the PATH. This is they key step that all Rails on Ubuntu install documents miss out. They are all located in:

/var/lib/gems/1.8/bin/

You can execute them directly from there by using the full path to the binary, but this is no good for automated tasks such as the Blacklight installer which expect the executables to be available. Also, you can’t just add this directory to your user’s PATH variable, as this will not propagate up into the root user’s PATH when sudo is used; Instead, you must symlink the binaries you want to use into an existing PATH location:

sudo ln -s /var/lib/gems/1.8/bin/rails /usr/bin/rails

sudo ln -s /var/lib/gems/1.8/bin/rake /usr/bin/rake

Install Blacklight

Now we can follow the install parts of the Blacklight documentation. This basically comes down to

rails ./blacklight-app -m http://projectblacklight.org/templates/latest.rb

Although it depends on which version of Blacklight you are trying to install. See their README for more detail.

Use the following answers to the questions posed by the installer (or don’t – this is just what we did):

  1. yes
  2. no
  3. yes
  4. yes
  5. no
  6. yes

Some install options may fail; since Blacklight installs Solr for you, but doesn’t start it, it will fail to load the default marc data. If your PATH isn’t set up properly (as described above) it will fail to run all the rake command; this can be fixed by sorting out the PATH (as described above) and running

sudo rake gems:install

rake db:migrate RAILS_ENV=development

Initialising Solr

Start the solr web service in the jetty directory

./blacklight-app/jetty$ java -jar start.jar

To confirm that it is up, visit the URL:

http://localhost:8983/solr/

If you want to install the demo marc data, in the blacklight directory run:

rake solr:marc:index_test_data

Starting Blacklight

Start the ruby server:

./blacklight-app$ ./script/server

to confirm that it is up, visit the URL:

http://localhost:3000/

And that’s it. Blacklight and Solr should now be up and running. Have fun with it!

Advertisements

One Response to Blacklight, Solr, Ruby and Rails on Ubuntu

  1. […] on Ubuntu was difficult, although not impossible, and we blogged a How-To guide which patched some holes in existing online guides. Results on Windows were variable, with issues […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: