← Back to Articles
The Tech Collective

Using a Raspberry Pi for your own Inventory Management System

Step-by-step guide to installing the Community Conduit inventory management system on a Raspberry Pi — LAMP stack setup, database configuration, file permissions, and network access.

Using a Raspberry Pi for your own Inventory Management System

A Raspberry Pi makes a surprisingly capable shared server for a small organization. This guide walks through setting up the Community Conduit inventory management system on a Pi — from installing the LAMP stack (Linux, Apache, MySQL, and PHP — the four open-source components that power most self-hosted web apps) to configuring the database and serving the web interface to everyone on your network.

An open-source, inventory management system written in PHP with a MySQL database has no problem operating on a Raspberry Pi. Initially, you’ll only have local network access, but if you want to allow remote web access, you can.

In order to setup a web interface to access, view, and manage the content of your inventory management system you’ll need to set up a LAMP stack on your Raspberry Pi and configure it to work as a web server and set up a basic website which you can access on any device on the same network as your Pi. This is a link to a nice tutorial for setting-up a L.A.M.P. server on your Pi, the WordPress portion is optional, you can stop after installing PHP.

If you plan on having access to your Raspberry Pi through the Internet, you’ll need to configure your router and DDNS settings, or use a service such as dataplicity.io to wormhole to your pi through the web.

Install the Basic Inventory Management System Web Application

Included Features:

InventoryProducts

After updating the Raspberry Pi and setting up the LAMP stack, installation of the inventory application is relatively painless.

If you haven’t done so, use apt-get to acquire and install the database software:

sudo apt-get install mariadb-server
sudo apt-get install php-mysql

When the installation is complete, run a simple security script that comes pre-installed with MariaDB which will remove some insecure default settings and lock down access to your database system. Start the interactive script by running:

sudo mysql_secure_installation

Download the source-code package and then you’ll need to extract the contents to the folder. Either rename the folder to the base name now or after you move it to the web root for Apache Web Server found at /var/www/html/

example:  sudo cp -R ~/Downloads/inventory-master /var/www/html/inventory

Use the MySQL/MariaDB command line to import the database schema.

Create a database named inventory and import the schema included in the project directory inventory.sql If you haven’t done so, installation is as easy as:

sudo mysql -uroot

mysql> CREATE DATABASE inventory;
mysql> USE inventory;
mysql> source /var/www/html/inventory/inventory.sql

mysql> CREATE USER 'webuser'@localhost IDENTIFIED BY 'p1r4sp';
mysql> GRANT ALL PRIVILEGES ON inventory.* TO 'webuser'@localhost;
mysql> FLUSH PRIVILEGES;

Edit the /includes/config.php to match the username and password used to access your database.

File Permissions Primer

Linux controls who can read, write, or run each file using a permissions system. Every file has an owner and a group, and each can have read, write, or execute permissions.

The commands below set the correct permissions so Apache can serve your files and write to the uploads directory:

The directory containing the project, especially, the uploads directory, must have write permissions on the system and let the web application run under the www-data account by executing the following commands from the project directory:

sudo chmod -R 775 uploads/
sudo chown -R www-data:www-data *

Edit the header.php file lines #19 – #22 to suit the needs of your organization. e.g. change to logo [project folder on server]/layouts/header.php Same folder also contains the various menus used by the system.

Edit the CSS at line #85 and #102 to reflect the needs of your organization. e.g. background color [project folder on server]/libs/css/main.css

InventoryAdmin

Using the Inventory Management System

Improvements

The following improvements are recommended before using this system for real organizational data. Security-critical items are marked with ⚠.

These are the improvements I’ve added for my own system

More Improvements

With permissions set, the database configured, and the web interface accessible on your network, your team can start tracking assets from any device on the same network — no spreadsheet juggling required.

Improved Version Source-Code

💬
Continue the conversation in the forum
Town Square · Community Tool Shed · The Tech Collective · Sustainable Communities · and more
Join the Forum →