How to Install Grocy on Linux Mint Latest

grocy.info/">Grocy is a free web-based self-hosted grocery and household management tool. With Grocy, you can easily manage your inventory, shopping list, recipes, and more. This tutorial will guide you through the steps of installing Grocy on your Linux Mint system.

Step 1: Update the System

Before installing any new software, it's essential to ensure that your Linux Mint system is up-to-date. Open a terminal and run the following command:

sudo apt update && sudo apt upgrade -y

Step 2: Install Dependencies

You need to install some packages required for Grocy to work correctly. Run the following command to install these dependencies:

sudo apt install nginx php php-fpm php-mbstring php-curl php-gd php-zip php-xml mariadb-server mariadb-client -y

After installing the dependencies, you need to set up a database for Grocy.

sudo mysql_secure_installation

Answer the prompts to secure your database installation and create a new database.

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

Step 3: Download and Extract Grocy

Next, you need to download the latest version of Grocy from the official website. Open a terminal and navigate to the directory where you want to download Grocy.

cd /tmp
wget https://releases.grocy.info/latest -O grocy_latest.zip

Extract the downloaded archive:

unzip grocy_latest.zip
sudo mv grocy /var/www/html/

Step 4: Configure Nginx

Create a new Nginx configuration file for Grocy:

sudo touch /etc/nginx/sites-available/grocy.conf
sudo nano /etc/nginx/sites-available/grocy.conf

Paste the following configuration into the file:

server {
    listen 80;
    server_name your_domain.com; # Put your domain name or IP address here
    root /var/www/html/grocy;

    location / {
        index index.php;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }

    if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        #
        # Custom headers and headers various browsers *should* be OK with but aren't
        #
        add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
        #
        # Tell client that this pre-flight info is valid for 20 days
        #
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain; charset=utf-8';
        add_header 'Content-Length' 0;
        return 204;
    }

    if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, X-Requested-With, Content-Type, Accept';
    }

    if ($request_method = 'GET') {
        add_header 'Access-Control-Allow-Origin' 'your_frontend_domain.com'; # Put your frontend domain name or IP address here
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, X-Requested-With, Content-Type, Accept';
    }
}

Save and close the file. Then, create a symbolic link from the configuration file to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/grocy.conf /etc/nginx/sites-enabled/

Test your Nginx configuration using:

sudo nginx -t

If everything is OK, reload the Nginx service:

sudo systemctl reload nginx

Step 5: Configure Grocy

Open your browser and navigate to http://your_domain.com. You should see the Grocy installation page. Follow the installation wizard to complete the installation.

During the installation, you'll be prompted to enter your MariaDB database details. Enter the following details:

After completing the installation wizard, you can access your Grocy installation by navigating to http://your_domain.com in your web browser.

Congratulations! You have successfully installed Grocy on your Linux Mint system. You can start using Grocy to manage your inventory, shopping list and more.

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!