Solr on Ubuntu, revisited

It's been a while since I first wrote about setting up Solr on Ubuntu. Since then I've opted for a different approach that is both simpler and lighter-weight. This post describes briefly the steps to setting up Solr on Ubuntu.

Fetching the code

First step is to get a copy of Solr:

cd /tmp/
wget http://apache.mirrors.tds.net//lucene/solr/1.4.1/apache-solr-1.4.1.tgz
tar xzf apache-solr-1.4.1.tgz

Installing

I create a "solr" user and just put the webapp and all the configuration data in that user's home directory:

# create the solr user
sudo useradd solr

# copy the solr executable and sample conf to the solr home dir
sudo cp -R apache-solr-1.4.1/example/ /home/solr/

cd /home/solr/

If you want to use a multi-core configuration, you'll need to shuffle around the default conf:

sudo mv solr/ single-core
sudo mv multicore/ solr

Lastly, change permissions:

sudo chown -R solr:solr .

Testing it out

Now you're ready to test the installation. From the /home/solr/ directory, run the following:

sudo su solr
java -jar start.jar

You should see a bunch of output with this at the end:

2011-06-17 16:39:18.320::INFO:  Started SocketConnector @ 0.0.0.0:8983

Solr's web interface is now available at:

http://your-server:8983/solr/

Using a process manager to start/stop Solr

I personally like supervisord for process management. Another popular option is upstart. These tools can make it easy to automatically start Solr and are a good replacement for the more old-school "init" scripts.

Here's what my supervisor conf looks like:

[program:solr]
command=java -Xmx128m -jar start.jar
directory=/home/solr/
user=solr
autostart=true
autorestart=true
redirect_stderr=true

Hope this helps!

Comments (1)

  1. Thanks man,

    This post and your previous one (http://charlesleifer.com/blog/how-to-...) was a very helpful step-by-step guide... no thought required, just cut, paste, enter, sorted.

Commenting has been disabled for this entry

If you'd like to discuss an aspect of this post, feel free to contact me via email.