How to Install Grocy on Arch Linux

Grocy is a free, open-source, and self-hosted web-based application that helps you manage your groceries and household supplies. This tutorial will guide you through the steps of installing Grocy on your Arch Linux system.

Prerequisites

Before you begin, you need to have the following prerequisites:

Step 1: Install Git

Git is required to clone the Grocy repository from Github. Run the following command to install Git:

sudo pacman -S git

Step 2: Install Nginx

Nginx is a web server used to host the Grocy application. Run the following command to install Nginx:

sudo pacman -S nginx

Step 3: Install PHP

Grocy is built using PHP. The following command will install PHP and some commonly used PHP extensions:

sudo pacman -S php php-fpm php-gd php-intl php-pdo php-sqlite php-mysql

Step 4: Clone the Grocy Repository

Now clone the Grocy repository from Github using the following command:

sudo git clone https://github.com/grocy/grocy /srv/http/grocy

Step 5: Configure Nginx

Create a new Nginx configuration file for Grocy:

sudo nano /etc/nginx/conf.d/grocy.conf

Add the following content into the file:

server {
    listen 80;
    server_name example.com;
    root /srv/http/grocy/public;
    index index.php;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

Save and close the file.

Step 6: Start Nginx and PHP-FPM

Now start the Nginx and PHP-FPM services:

sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl enable php-fpm
sudo systemctl start php-fpm

Step 7: Configure the Database

Grocy requires a database to store its data. You can use either MySQL or SQLite.

Using MySQL

If you want to use MySQL, you need to create a new database and user for Grocy. Run the following commands to create a new database and user:

mysql -u root -p
CREATE DATABASE grocy;
CREATE USER 'grocy'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON grocy.* TO 'grocy'@'localhost';
FLUSH PRIVILEGES;
exit;

Using SQLite

If you want to use SQLite, you need to create a new SQLite database file:

sudo touch /srv/http/grocy/data/grocy.db
sudo chown http:http /srv/http/grocy/data/grocy.db

Step 8: Configure Grocy

Copy the sample configuration file and modify it for your environment:

sudo cp /srv/http/grocy/data/config-dist.php /srv/http/grocy/data/config.php
sudo nano /srv/http/grocy/data/config.php

Set the database connection settings according to your chosen database:

// MySQL settings
define('GROCY_DB_CONNECTION_STRING', 'mysql:host=localhost;dbname=grocy');
define('GROCY_DB_USERNAME', 'grocy');
define('GROCY_DB_PASSWORD', 'password');

// SQLite settings
define('GROCY_DB_CONNECTION_STRING', 'sqlite:/srv/http/grocy/data/grocy.db');
define('GROCY_DB_USERNAME', null);
define('GROCY_DB_PASSWORD', null);

Save and close the file.

Step 9: Open Grocy in Your Browser

Open your web browser and go to http://localhost. You should see the Grocy homepage.

Congratulations, you have successfully installed Grocy on Arch Linux!

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!