I used Ubuntu 8.10 in this article but the instructions will probably work on 8.04 and 7.10 as well. I've not tested those though, and I'm not sure if it'll work on other versions of Ubuntu. Feedback would be awesome.


ActiveMQ is a Java aplication so, well, you'll need Java installed.

sudo apt-get install openjdk-6-jre

Installing ActiveMQ

  1. Grab the latest stable release using wget. I used 5.2.0.
    wget http://www.apache.org/dist/activemq/apache-activemq/5.2.0/apache-activemq-5.2.0-bin.tar.gz
  2. Unpack it somewhere. I use /usr/local although I believe this may be bad practice. Leave a comment if there's somewhere better for this!
    sudo tar -xzvf apache-activemq-5.2.0-bin.tar.gz -C /usr/local/
  3. Configure the broker name in /usr/local/apache-activemq-5.2.0/conf/activemq.xml (replace all instances of "localhost" with the actual machine name)
  4. Start ActiveMQ by running /usr/local/apache-activemq-5.2.0/bin/activemq
  5. Fire up a browser and browse to http://brokername:8161/admin. You should see the ActiveMQ admin console.

Keeping ActiveMQ running

Running ActiveMQ (or indeed any service you don't absolutely have to) as root is a Bad Idea. Create an activemq user and make the data directory be owned by them.

sudo adduser --system activemq
sudo chown -R activemq /usr/local/apache-activemq-5.2.0/data

I run ActiveMQ under DaemonTools to make sure it's always up. If you haven't already, install DaemonTools.

Create a service directory for activemq and populate it with the required scripts.

sudo mkdir -p /usr/local/apache-activemq-5.2.0/service/activemq/{,log,log/main}

/usr/local/apache-activemq-5.2.0/service/activemq/run should look like this.

exec 2>&1


exec softlimit -m 1073741824 \
     setuidgid $USER \

/usr/local/apache-activemq-5.2.0/service/activemq/log/run should look like this.

exec setuidgid $USER multilog t s1000000 n10 ./main

Make both run scripts exectuable, the log/main directory owned by activemq and symlink the activemq service directory into /etc/service/.

sudo sh -c "find /usr/local/apache-activemq-5.2.0/service/activemq -name 'run' |xargs chmod +x,go-wr"
sudo chown activemq /usr/local/apache-activemq-5.2.0/service/activemq/log/main
sudo ln -s /usr/local/apache-activemq-5.2.0/service/activemq /etc/service/activemq

Now turn the keys and start it up.

sudo svc -u /etc/service/activemq

Tail the logs to make sure everything is happening as you'd expect.

sudo tail -F /etc/service/activemq/log/main/current


When I did this I got a bunch of stack traces with the following message.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: java.io.FileNotFoundException: /usr/local/apache-activemq-5.2.0/data/kr-store/state/hash-index-store-state_state (Permission denied)

This was because I stopped ActiveMQ after I changed ownership of the data directory causing it to dump the state file owned by another user. If you get the same problem just change the ownership of the data directory again.


Thanks to Sean O'Halpin who introduced me to message queues and ActiveMQ (but who doesn't have a homepage or blog that I can link to) and Dave Evans who introduced me to Daemon Tools.

written by
Disagree? Found a typo? Got a question?
If you'd like to have a conversation about this post, email craig@barkingiguana.com. I don't bite.
You can verify that I've written this post by following the verification instructions:
curl -LO http://barkingiguana.com/2008/12/13/deploying-activemq-on-ubuntu-810.html.orig
curl -LO http://barkingiguana.com/2008/12/13/deploying-activemq-on-ubuntu-810.html.orig.asc
gpg --verify deploying-activemq-on-ubuntu-810.html.orig{.asc,}