How to install PiggyDB on a Raspberry PI

Using Jetty for rocket performances


The Raspberry PI is a neat small computer. It can do a lot without consuming large amount of energy but it does require to use really efficient applications as its CPU is a really small one.

If you don’t know PiggyDB yet, go have a look. To make it short, it’s your personal wikipedia. You can tag fragments (= an article), upload pictures or files, use its search engine to find what you stored in here. The smaller your fragments are, the better I think. Main features I forgot to speak about : Zero setup and it’s web application (Nothing to install anywhere else!).


Step 1 : Installing Java + Jetty

Note: I’m assuming the PI is running Raspbian.

Fire your average SSH session and run the following : sudo apt-get update && sudo apt-get install oracle-java7-jdk && sudo apt-get install jetty

  • It will update its source list
  • Install Oracle Java 7 JDK (If not already there)
  • Install Jetty (To run our web application)
Still some work to do.

Step 2: Editing Jetty Configuration

ls -al /usr/lib/jvm/

Let’s do a quick ls -al /usr/lib/jvm/ and take note of the jdk folder name.

Now, we’ll edit jetty configuration : sudo nano /etc/default/jetty

  • Allow jetty to start: NO_START=0
  • Un-comment (remove the # at the start of the line) JETTY_HOST=
  • Allow Jetty to listen also to IP Adresses (Useful when you don’t have a proper DNS Server like your ISP Set-Top Box: JETTY_HOST=0.0.0.0
  • Un-comment JDK_DIRS=
  • Define where java is with: JDK_DIRS=”/usr/lib/jvm/jdk-7-oracle-armhf”

Press ctrl + x, then press Y and finally enter to save your changes.

Step 3: Start and test Jetty

Type this command to start jetty: sudo /etc/init.d/jetty start

Started and reachable. If it’s not started, have a look into /var/log/jetty folder.

Using your browser or lynx, try to open the default webpage on port 8080.

Jetty default page, proving that it’s working !

Now we know it’s working, let’s stop jetty: sudo /etc/init.d/jetty stop

Step 4: Creating a folder and downloading PiggyDB

PiggyDB is storing its database in a folder at the same level than webapps folder. As it may not be able to create it by itself, let’s help it:

sudo mkdir -m 755 /usr/share/jetty/piggydb && sudo chown jetty:jetty /usr/share/jetty/piggydb

All PiggyDB flavours on sourceforge.

PiggyDB is available in multiple versions : Local for Windows/OS X and direct .war files for our scenario. We’ll use the “anonymous” version that doesn’t require to have an account to read fragments from a PiggyDB database. (Creating or editing a fragment does require it)

Find the latest version of piggydb-x.xx-anonymous.war package and copy the link.

Now, let’s download PiggyDB to webapps directory : sudo wget -O /usr/share/jetty/webapps/piggydb.war http://sourceforge.net/projects/piggydb/files/Piggydb/6.18/piggydb-6.18-anonymous.war/download

Everything is now in place !

Step 5: Last jetty launch and PiggyDB test

Type this command to start jetty (again): sudo /etc/init.d/jetty start

Open your favorite browser with http://<ip-address-or-name>:8080/piggydb/ and you should see something.

Ready to accept new fragments, after login with owner/owner.

If you’re not seeing that, have a look to /var/log/jetty directory, especially the stderrout.log. It will help you find why it didn’t work.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.