How to Install Grocy on NetBSD

Grocy is a self-hosted web-based application that allows you to manage your groceries, recipes, inventory, and more. In this tutorial, we will guide you on how to install Grocy on NetBSD.

Prerequisites

Before installing Grocy, you need to ensure that your NetBSD system meets the following requirements:

Step 1: Install Required Packages

Update the system package repository by running the following command:

sudo pkgin update

Then, proceed to install the required packages for Grocy by running the following command:

sudo pkgin install php74-apache php74-pdo_mysql php74-json php74-curl php74-mbstring php74-mysql php74-simplexml composer unzip

Step 2: Download and Extract Grocy

  1. Create a directory where you want to install Grocy. For example:

    sudo mkdir /var/www/grocy
    
  2. Change to the newly created directory.

    cd /var/www/grocy
    
  3. Download the latest version of Grocy from the official website by running the following command:

    sudo wget https://releases.grocy.info/latest
    
  4. Extract the downloaded archive by running the following command:

    sudo unzip latest -d /var/www/grocy
    
  5. Change the owner of the Grocy directory to the web server user.

    sudo chown -R www:www /var/www/grocy
    

Step 3: Create a Database and User for Grocy

  1. Log in to your MySQL/MariaDB server using the following command:

    mysql -u root -p
    
  2. Create a new database for Grocy by running the following command:

    CREATE DATABASE grocy;
    
  3. Create a new user for Grocy and grant all privileges to the grocy database. Replace grocyuser and password with your desired username and password.

    CREATE USER 'grocyuser'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON grocy.* TO 'grocyuser'@'localhost';
    FLUSH PRIVILEGES;
    
  4. Exit the MySQL/MariaDB console by running the following command:

    exit
    

Step 4: Configure Grocy

  1. Copy the example configuration file to a new file.

    sudo cp /var/www/grocy/config-dist.php /var/www/grocy/data/config.php
    
  2. Open the newly created config.php file using a text editor.

    sudo nano /var/www/grocy/data/config.php
    
  3. Modify the following lines to reflect your MySQL/MariaDB configuration:

    define('GROCY_DB_HOST', 'localhost');
    define('GROCY_DB_NAME', 'grocy');
    define('GROCY_DB_USERNAME', 'grocyuser');
    define('GROCY_DB_PASSWORD', 'password');
    
  4. Save and close the file.

Step 5: Install Grocy

  1. Change to the Grocy directory.

    cd /var/www/grocy
    
  2. Install the required dependencies by running the following command:

    sudo composer install --no-dev
    
  3. You should see some output in the terminal. Wait for the process to complete.

Step 6: Configure Apache

  1. Open the Apache configuration file using a text editor.

    sudo nano /usr/pkg/etc/httpd/httpd.conf
    
  2. Find the following lines and uncomment them by removing the # character:

    LoadModule deflate_module lib/httpd/mod_deflate.so
    LoadModule rewrite_module lib/httpd/mod_rewrite.so
    LoadModule php7_module lib/php/20200930/php7apache2_4.so
    
  3. Scroll down to the end of the file and add the following lines:

    <Directory "/var/www/grocy">
     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted
    </Directory>
    
  4. Save and close the file.

Step 7: Restart Apache

  1. Restart the Apache server using the following command:

    sudo /etc/rc.d/apache restart
    

Step 8: Access Grocy

  1. Open your web browser and navigate to the following URL:

    http://localhost/grocy
    
  2. You should see the Grocy login screen. Use the default username admin and password admin to log in.

Congratulations! You have successfully installed Grocy on NetBSD. You can now start using Grocy to manage your groceries, recipes, inventory, 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!