When Raspberry PI came out in early 2012, I had to get my hand on one. I didn’t know what I would do with it but the tiny size of that little computer made me have it. I bought one after waiting 6 weeks on back order. First thing I installed on that machine was Java and then Tomcat application server just to see if my favorite language and app server would run from a tiny thing. Well then years has passed and didn’t spend any time on it.Few days back I thought why not make a tiny map server out of Raspberry Pi. Here I’m inviting you on a tiny journey with me hoping that it would amazes you too to see how a tiny machine serves maps.
Raspberry Pi Model B
First let me list out software and operating systems involved in this tiny lab.
- Operating System:RASPBIAN Debian Wheezy Version:September 2014
- Java Servlet Server:Tomcat 7
- GIS Map Server:Geoserver
- A Client:A Windows 7 Laptop
- SSH Client:Putty on Windows
Install Operating System
For this lab I went with Raspbian Wheezy. It is a variant of Debian and one of the matured operating system made specially for Raspberry Pi. Download Raspbian from here. A detail instruction on how to install Rasbian image on a sd card also can be found here. Once you have the SD card you are all set to start Raspberry PI. Start Raspberry Pi.
Using Raspberry PI as Headless Server
For this lab we will use Raspberry PI in headless mode. Raspberry Pi can be run just like a regular computer using a monitor, keyboard and mouse. I’m choosing to run the little machine more like a remote server aka “headless mode”.
SSH to Raspberry Pi
We will use a laptop running Windows 7 to connect to our Raspberry Pi box. SSH protocol can be used to connect. In order to use SSH we will need to know the ip address that Raspberry Pi is running of off. We can find ip address in two different methods. Both of these methods are nicely describe here.
Using Router to find Raspberry’s IP
Log in to router’s web admin console. In my case the address to admin console was http://192.168.11.1. From the control panel find the list of connected devices to router. From the list figure out the ip address of Raspberry Pi and note it down. In my case the ip was 192.168.11.131.
Using namp to find Raspberry’s IP
Download and install nmap. namap is a free networking utility to find ip and mac addresses inside a network. Running the following command will display all connected devices in network. Let us type up the following command to display a list of connected devices. In this lab our subnet is 192.168.11.xxx
nmap -sP 192.168.11.0/24
Here is sample console out. In this situation raspberrypi can be identified to have ip address of 192.168.11.131
Using Putty to SSH
Install Putty if not installed already and start it up. Type in the IP address that was found in our previous step. Click open. SSH console would be displayed. Type in user as pi and provide appropriate password to login. You should be connected to Pi now.
Install Java Servlet Server
In recent versions of Raspbian image distribution Oracle Java 1.8 is already bundled.
In this lab we will install and use Tomcat version 7 as the servlet server. A servlet container is required to run Geoserver GIS map server which we intend to use as our spatial server. We would type the following command to install Tomcat 7.
sudo apt-get install tomcat7
Most likely the process will run into a JAVA_HOME not found problem as illustrated below whilte trying to start up tomcat instance.
This problem can be solved by adding JAVA_HOME to /etc/default/tomcat7 file. Add the following line to the file using a file editor like vi or vim.
Let us now start Tomcat instance by typing the following command.
sudo service tomcat7 start
Let us test Tomcat7 installation by using a browser and connecting to the default landing page. Type up the following address in a browser where the IP address is pointing to the IP address of the Raspberry Pi.
A successful Tomcat installation would present a page as displayed as follows.
Install Geoserver Map Server
Download Geoserver war zip
Now unzip the archive to extract WAR file by typing the following.
Let us stop Tomcat server
sudo service tomcat7 stop
Now let us move the war to Tomcat’s webapps folder. The webapps folder is located under
/var/lib/tomcat7/webapps . Let us move the war by typing up the following.
sudo mv geoserver.war /var/lib/tomcat7/webapps
sudo service tomcat7 start
Login to Geoserver admin console by typing
You should be presented with the Geoserver login page. Now type in admin as user id and geoserver as password to log into Geoserver admin console. A successful login will present us with a page like as shown here.
Click on “Layer Preview” tab on the left to bring up layer preview page.
Now click on “OpenLayers” link for topp:states USA Population. We should be presented by a preview of USA States map as shown below.
This will bring to an end of my Tiny Map server demo. In future I may present with more tutorial like this one if I get enough interest. I wish to create a series on how to create web based Maps based on open source and commercial server and client products. Thanks for reading.