Making a RaspberryPi Server

Raspberry Pi

The RaspberryPi is an amazing tiny computer useful for all sorts of projects, here I discuss deploying it as Database and Webserver for Aughton Village Hall.

Shopping List

Getting Started

When you have the your RaspberryPi you just need to assemble it inside the case, add the
When you plug in the power adapter the Raspberry Pi will boot, if you just have Noobs on the SD-card it will boot into the installer.



  • Follow the on-screen setup
    Enable SSH under the advanced options
    Take not of your current IP address,
    Set a meaningful hostname,
    In our final system, the RaspberryPi will operate without a KVM (keyboard, video and mouse) and will be a headless server, however you can add these if you wish, but you must make you server static so your till points can talk to it.

    Finding your ip address
    ip addr
    pi@aughtonvillagehall ~ $ ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
    valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether b8:27:eb:3d:55:3d brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
    valid_lft forever preferred_lft forever
    3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether 00:13:ef:40:0e:42 brd ff:ff:ff:ff:ff:ff

    pi@aughtonvillagehall ~ $ ifconfig
    eth0 Link encap:Ethernet HWaddr b8:27:eb:3d:55:3d
    inet addr: Bcast: Mask:
    RX packets:10953 errors:0 dropped:17 overruns:0 frame:0
    TX packets:1785 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:8440683 (8.0 MiB) TX bytes:198405 (193.7 KiB)

    lo Link encap:Local Loopback
    inet addr: Mask:
    UP LOOPBACK RUNNING MTU:65536 Metric:1
    RX packets:142 errors:0 dropped:0 overruns:0 frame:0
    TX packets:142 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:15390 (15.0 KiB) TX bytes:15390 (15.0 KiB)

    wlan0 Link encap:Ethernet HWaddr 00:13:ef:40:0e:42
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)


    sudo apt-get update
    sudo apt-get upgrade
    Y: confirm updates

    LAMP Stack

    The backend to Unicenta is just a database, you can choose MySQL or Postgres.

    sudo apt-get install apache2 php5 libapache2-mod-php5
    sudo apt-get install mysql-server mysql-client php5-mysql

    Ref: DB comparison:

    If you get:
    Reloading web server config: apache2apache2: Could not reliably determine the server’s fully qualified domain name, using for ServerName
    Set the ServerName in the config


    PIP is a python package manager.
    Python Unicenta tools are written in Python, because I wrote them of course I’d recommend them, but I’ll let you make your own mind up.
    If you want to run UnicentaPython for producing reports or doing admin, then you will need it.

    Install Python MySQL Connection

    Find your System name: uname, uname -or
    Find your Debian Version: cat /etc/debian_version
    We’re using Debian in this project
    You need to check your driver is compatible
    Get the MySQL Connector from the MySQL website
    It will
    Get your driver from
    Select Debian/Ubuntu
    You will be asked to login, but click the link to avoid this underneath

    ssh ing in:
    ssh pi@ipaddress
    password as chosen

    Graphical Connections
    Require X11 client (your machine)
    ssh -X pi@ipaddr
    pi@aughtonvillagehall ~ $ java -version
    java version “1.8.0”
    Java(TM) SE Runtime Environment (build 1.8.0-b132)
    Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)

    NOOBS Setup

    We will be setting up the RaspberryPi to do some cool stuff for Unicenta. You don’t have to use the RaspberryPi to do all of these and you may wish to use it to do other things too.
    Remember the RaspberryPi is a tiny computer, don’t overwork it.

    Database Server
    The database for your ePOS system
    Web Server: Information
    Show some simple staff pages
    Web Server: Admin
    Provide some Admin functionality online
    UnicentaPython API. Provide UnicetaReports, UnicentaAdmin and UnicentaMobile functionality backend.
    Unicenta Download
    Allow tills to update unicenta remotely

    MySQL Driver
    You will need to build this from sources
    Don’t use the package is my advice, it took me 2 hours to install, reinstall, de-install, purge and make it eventually go away
    It doesn’t work
    Building from source is easy
    tar -zxvf mysql …
    cd mysql…
    sudo python install

    import mysql.connector

    Setting up SSH keys

    Add some new users
    I would recommend giving you (the admin) a personal account and the staff user

    $sudo adduser martyn
    follow prompts
    $sudo useradd -N pos -p pos
    Create a new user without there own group, and the password pos, same s the user
    Syntax: # useradd -s -m -d -g UserName
    Or use adducer for an interactive version

    Mysql User
    Login to MySQL
    Give yourself Admin privileges
    mysql -uroot -pavh102010
    mysql> CREATE USER ‘martyn’@’localhost’ IDENTIFIED BY ‘ncis99Secure’;
    Query OK, 0 rows affected (0.01 sec)

    mysql> GRANT ALL PRIVILEGES ON * . * TO ‘martyn’@’localhost’;
    Query OK, 0 rows affected (0.00 sec)
    Reload Privs, not sure if this matters
    Query OK, 0 rows affected (0.01 sec)

    Setup MySQL to listen on all address

    Instead of skip-networking the default is now to listen only on

    localhost which is more compatible and is not less secure.

    #bind-address =
    This allows MySQL to listen to all adresses, otherwise unite can’t talk to MySQL!

    Then sudo /etc/init.d/mysql restart

    Then add your user on to none-local addresses
    CREATE USER ‘martyn’@’%’ IDENTIFIED BY ‘ncis99Secure’;

    mysql> CREATE DATABASE AughtonVillageHall;
    Query OK, 1 row affected (0.00 sec)
    We are loading our existing sales to here

    Configure with Ansible
    Securing your Server
    Protection your data