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
As usual, I suggest adding from now to your favourite ecommerce shopping chart all needed hardware, so that at the end you will be able to evaluate overall costs and decide if continuing with the project or removing them from shopping chart. So, hardware will be only:
- Raspberry PI Zero W (including proper power supply or using a smartphone micro usb charger with at least 3A) or newer Raspberry PI Board
- high speed micro SD card (at least 16 GB, at least class 10)
Check hardware prices with following links:
Install Apache webserver, SQLite and PHP (with required packages):
sudo apt install apache2 # installs Apache web Server sudo apt install sqlite3 # installs sqlite sudo apt install php7.3 php7.3-sqlite3 php7.3-gd # installs PHP and required packages
Get a copy of Grocy code:
wget https://releases.grocy.info/latest -O grocy.zip
Unzip inside Apache root folder, copy config file from template and give correct permission to folder:
sudo unzip grocy.zip -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
Enable Override in Apache:
sudo nano /etc/apache2/apache2.conf
Edit under “<Directory /var/www>” row:
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 192.168.1.78, my browser is Brave browser). The login page will appear:
Use default credentials (remember to change password as soon):
- user: admin
- password: admin
You will be logged in to Grocy default home page:
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 192.168.1.78). you web browser will notify a not verified certificate with a not secure 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:
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.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?