Manage your home stocks like a pro with Grocy and Raspberry PI


Managing home stocks is a common need for all people. How many times did you forget to buy something finished at home from your supermarket?

Grocy aims to help people keeping track of their stocks and easily plan shopping of required items. With its built-in barcode scan function, it also allows to manage your products quantity simply scanning their barcode with your smartphone/tablet/pc camera.

It also supports a wider number of items and elements, also letting you to define your customized ones.

Its main features include:

  • Google Home Assistant integration
  • Purchases tracking
  • Shopping list automation and optimization
  • Recipes management
  • Meal planning
  • Tasks management
  • … and many other features and addons

In this guide, Grocy will be installed in a cheap Raspberry PI Zero W, but this applies also to newer Raspberry PI boards.

What We Need

Raspberry PI Zero W unpopulated

As usual, I suggest adding from now to your favourite e-commerce shopping cart all needed hardware, so that at the end you will be able to evaluate overall costs and decide if continue with the project or remove them from the shopping cart. So, hardware will be only:

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon raspberry pi Zero W box
Amazon Micro SD box
Amazon Raspberry PI Power Supply box

Step-by-Step Procedure

Install Apache webserver and SQLite:

sudo apt install apache2 # installs Apache web Server
sudo apt install sqlite3 # installs sqlite

With recent changes in Grocy, php7.3 seems to be no longer supported. At the date of this article php7.4 is not available from Raspberry PI repositories. So we have 2 options:

  • harder way: compiling php7.4 from sources
  • easier way: use addictional repositories prepared from developers

This guide will follow second way. Add Sury repository with these commands:

sudo apt install -y apt-transport-https lsb-release ca-certificates wget
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg
echo "deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update

And install php packages:

sudo apt install php7.4 php7.4-sqlite3 php7.4-gd

Get a copy of Grocy code:

wget -O

Unzip inside Apache root folder, copy config file from template and give correct permission to folder:

sudo unzip -d /var/www/html/
sudo cp /var/www/html/config-dist.php /var/www/html/data/config.php
sudo chown www-data:www-data -R /var/www/html/

Define base path in Apache:

sudo nano /etc/apache2/sites-available/000-default.conf

edit from

DocumentRoot /var/www/html/


DocumentRoot /var/www/html/public/

Enable Override in Apache:

sudo nano /etc/apache2/apache2.conf

Edit under “<Directory /var/www>” row:

AllowOverride None


AllowOverride All

Enable Rewrite and restart Apache:

sudo a2enmod rewrite
sudo systemctl restart apache2.service

From your favourite browser, use your Raspberry PI url: “http://<<YourRpiIpAddress>>” (my Raspberry PI address is, my browser is Brave browser). The login page will appear:

Grocy Login page

Use default credentials (remember to change password as soon):

  • user: admin
  • password: admin

You will be logged in to Grocy default home page:

Grocy Stock Overview

From here, you can use your Grocy installation.

Enabling Barcode Scanner

If you want to use the convenient Barcode Scanner feature, you nee moving your Grocy installatio to htts. To enable SSL and make barcode scan working, please refer following steps.

You will install certificates generated locally, so your browser will surely notify you that this connection is not secure because it cannot verify with a public certification authority.

Enable Apache ssl, create a folder for certificates and generate local certificates. From terminal:

sudo a2enmod ssl
sudo mkdir /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

Last command will ask some questions for certificates generation. Answers are free…

Setup Apache ssl configuration file with correct root directory:

sudo nano /etc/apache2/sites-available/default-ssl.conf

Identify the row including “DocumentRoot /var/www/html/” and change it to “DocumentRoot /var/www/html/public”. Enable SSL and restart Apache:

sudo a2ensite default-ssl.conf
sudo systemctl restart apache2.service

Back to your browser, you will find the SSL page at “https://<<YourRpiIpAddress>>” (my address is still you web browser will notify a not verified certificate with a not secure warning:

SSL not secure page warning

You are using your local Raspberry Pi, so you can go on by clicking to “Advanced” and then “Proceed” link. A new login page will appear (identical to previous one), but at left side of your url the “Not Secure” warning will change and clicking it you will see that the notification comes from a not valid certificate:

Grocy Login page on https without valid certificate

However, you can login and use your Grocy installation and the Barcode Scanner feature.

If you want to get a correct certificate, you will need to get it from a Certification Authority (like, for example, the free SslForFree or using Let’s encrypt.


How useful was this post?

Click on a star to rate it anonymously!

Average rating 4.7 / 5. Vote count: 9

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?