Grocy is an open-source software for managing household groceries and inventory. It is perfect for people who want to keep an inventory of their groceries and want to keep track of the best-before dates of their food. In this tutorial, we will guide you through the process of installing Grocy on Clear Linux.
Before we start, you need to ensure that you have:
The first step is to install the required dependencies for Grocy. Open the terminal and type:
sudo swupd bundle-add nginx php-basic mariadb
This will install Nginx, PHP, and MariaDB on your system.
Composer is a dependency manager for PHP. It is used to install and manage PHP packages. To install Composer, run the following command:
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Now we are ready to install Grocy. First, create a directory where you want to install Grocy:
sudo mkdir -p /var/www/grocy
Change the ownership of the directory to your user. Replace USERNAME with your username:
sudo chown USERNAME:USERNAME /var/www/grocy
Now, change to the directory:
cd /var/www/grocy
Clone the Grocy repository:
sudo git clone https://github.com/grocy/grocy.git
Cd into the Grocy directory:
cd grocy
Install the PHP dependencies using Composer:
sudo composer install --no-dev
Grocy needs an Nginx server to run. Open Nginx's virtual host file:
sudo nano /etc/nginx/sites-available/default
Delete everything in the file and paste the following configuration:
server {
listen 80;
server_name example.com; # Replace example.com with your domain name
root /var/www/grocy/grocy;
index index.php;
access_log /var/log/nginx/grocy.access.log combined;
error_log /var/log/nginx/grocy.error.log;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Replace php7.4-fpm with your PHP version
}
}
Save and close the file.
Restart Nginx:
sudo systemctl restart nginx
Grocy needs a database to store its data. We will use MariaDB for this purpose. First, log in to the MySQL shell:
sudo mysql -u root
Create the Grocy database:
CREATE DATABASE grocy;
Create a new user and grant permission to the database:
CREATE USER 'grocyuser'@'localhost' IDENTIFIED BY 'password'; # Replace password with your strong password
GRANT ALL PRIVILEGES ON grocy.* TO 'grocyuser'@'localhost';
Flush the privileges and exit:
FLUSH PRIVILEGES;
exit;
Now we need to configure Grocy. Copy the configuration file:
cp ~/var/www/grocy/grocy/data/config-dist.php ~/var/www/grocy/grocy/data/config.php
Open the configuration file:
sudo nano /var/www/grocy/grocy/data/config.php
Change the following lines with your database details:
'database' => [
'host' => 'localhost',
'database' => 'grocy',
'username' => 'grocyuser',
'password' => 'password',
],
Remember to replace the database, host, username, and password values with your own details.
Save and close the file.
Open your favorite web browser and go to http://your-server-ip. You should see the Grocy login page. Congratulations! You have successfully installed Grocy on Clear Linux.
In this tutorial, we have shown you how to install Grocy on Clear Linux. We hope you found this tutorial helpful. Grocy is an excellent tool for managing your household groceries and inventory. Give it a try and see how it can help you.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!