Koha on a Raspberry Pi 4
These instructions cover setting up the latest version of Koha 19.05 on a Raspberry Pi 4. I focus on the Raspberry specialties and don't cover the Koha setup process in particular. For this I refer to the existing Koha documentation. Also the network-setup is described only rudimentary, here you can find more detailed instrustions on how to setup IP-adresses and domains with apache.
The complete setup was done via console / SSH / putty, so no monitor or additional hardware next to the Pi itself was needed.
Overview
Stages for installing Koha on a Raspberry Pi 4:
- Install Raspbian Lite (Minimal image based on Debian Buster)
- Setup System
- Add the Koha package source information
- Install Koha & MariaDB
- Configure Koha installation
- Benchmarking system
- General reference
Install Raspbian Lite (Minimal image based on Debian Buster)
You need to have a working install of Raspbian Lite, which is a minimal Debian Buster install. I used Raspbian Buster Lite image from 2019-09-26
Refer to the Raspberry Pi website - they have some good documentation.
Format an SD Card as FAT32 & write downloaded Raspbian image on card
Setup System
1. Create an empty file called "ssh" on boot partition to enable ssh server after startup
2. Create a textfile called "wpa_supplicant.conf" on boot partition to enable WLAN with following content:
country=DE ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="<your wlan-ssid>" psk="<your password>" key_mgmt=WPA-PSK }
3. Put he SD card in your Raspberry and boot the system. After some time you should be able to logon to your Raspberry via hostname "raspberrypi" and user "pi" with password "raspberry" via SSH Of course you can plug in keyboard & monitor to the Pi to work locally on the Pi, too.
You can now setup locales / timezones or any other system configuration you like via
$ sudo raspi-config
Add the Koha package source information
Add the source information & key for the Koha package:
$ echo deb http://debian.koha-community.org/koha stable main | sudo tee /etc/apt/sources.list.d/koha.list $ wget -O- http://debian.koha-community.org/koha/gpg.asc | sudo apt-key add -
Update all packages & upgrade to the latest version:
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get clean
Install Koha & MariaDB
Install Koha package and MariaDB:
$ sudo apt-get install koha-common mariadb-server
Note: This will take a while as it downloads and installs all the packages required for Koha.
Secure your MariaDB (e.g. delete unnecessary tables):
$ sudo mysql_secure_installation
Here you can confirm all suggested default-answers
Koha needs an additional perl module Mojolicious::Plugin::OpenAPI, so install it with:
$ sudo perl -MCPAN -e shell
confirm all and enter:
install Mojolicious::Plugin::OpenAPI
If everything went fine, you can exit the shell again.
If you want another language for your Koha, now would be a good time to install it. Here an example for adding german language support:
$ sudo koha-translate --install de-DE
Configure Koha installation
We need to configure our apache2 / web server configuration to use some needed modules & restart it after that
$ sudo a2enmod deflate rewrite cgi headers proxy_http $ sudo service apache2 restart
Now it's time to create our first library:
$ sudo koha-create --create-db <library-name>
and configure it in apache:
$ sudo a2ensite <library-name> $ sudo service apache2 restart
To access the Koha installation we have to edit some config files, I chose to access the staff page via a seperate port, so I entered port 8080 in the following file for intranet access: /etc/apache2/sites-enabled/<library-name>.conf
$ sudo nano /etc/apache2/sites-enabled/<library-name>.conf
and make sure apache listens on port 8080 as well. Therefor, add "Listen 8080" to
$ sudo nano /etc/apache2/ports.conf
Before we restart apache service again, we can also enable & start plack-service to speed up our installation
$ sudo koha-plack --enable <library-name> $ sudo koha-plack --start <library-name> $ sudo service apache2 restart
To access the web-installer you have to find out your password for your previously installed instance:
$ sudo koha-passwd <library-name>
Now, you should be able to get access to the web installer from Koha via accessing http://raspberrypi:8080 in your browser & logon via user koha_<library-name> with the just identified password. At this point I refer to the Koha setup process, because it's not really Raspberry/Raspbian specific anymore Web-Installer.
Benchmarking system
Now to the interesting part: How fast is a Raspberry Pi 4 with its quad-core 1,5GHz ARM-cpu? I used the 4GB RAM model for the following benchmark, but my library isn't not really large. So, I guess the 1GB model would be sufficient too, since my memory footprint is not really high. My tested library consists of ~800 books/items with ~150 patrons & 40 checkins/-out per week (small school library). I used script benchmark_staff.pl from the official Koha Github site and scored the following times:
$ ./benchmark_staff.pl --url=http://raspberrypi:8080/cgi-bin/koha/ --user=<admin> -password=<password>
Authentication successful -------------- Koha STAFF benchmarking utility -------------- Benchmarking with 20 occurrences of each operation and 30 concurrent sessions Step 1: staff client main page 62ms 322.58 pages/sec Step 2: catalog detail page 61ms 327.868 biblios/sec Step 3: catalogue search 61ms 327.868 biblios/sec Step 4: patron detail page 62ms 322.58 borrowers/sec Step 5: patron search page 126ms 317.46 borrowers/sec Step 6a circulation (checkouts) 61ms 327.868 checkouts/sec Step 6b circulation (checkins) 92ms 217.391 checkins/sec all transactions at once 352ms 511.363 operations/sec
I think these are very good response times considering that this is a ~$40-hardware that runs a complete ILS-System.
General reference
Raspberry Pi community:
Raspberry Pi Guides:
Previous instructions:
- https://wiki.koha-community.org/wiki/Koha_on_a_Raspberry_Pi
- https://wiki.koha-community.org/wiki/Koha_on_a_Raspberry_Pi_2
- https://wiki.koha-community.org/wiki/Koha_on_a_Raspberry_Pi_3_B%2B
Apache web server commands:
- Show Apache modules installed and enabled: apache2ctl -M
- Restart Apache: service apache2 restart
Change to root user (not recommended - use sudo instead):
- Change to the root user: sudo su