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:
- NetBSD 9.1 or later version
- Apache server and PHP installed
- MySQL/MariaDB server installed
- Composer installed
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
Create a directory where you want to install Grocy. For example:
sudo mkdir /var/www/grocyChange to the newly created directory.
cd /var/www/grocyDownload the latest version of Grocy from the official website by running the following command:
sudo wget https://releases.grocy.info/latestExtract the downloaded archive by running the following command:
sudo unzip latest -d /var/www/grocyChange 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
Log in to your MySQL/MariaDB server using the following command:
mysql -u root -pCreate a new database for Grocy by running the following command:
CREATE DATABASE grocy;Create a new user for Grocy and grant all privileges to the grocy database. Replace
grocyuserandpasswordwith your desired username and password.CREATE USER 'grocyuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON grocy.* TO 'grocyuser'@'localhost'; FLUSH PRIVILEGES;Exit the MySQL/MariaDB console by running the following command:
exit
Step 4: Configure Grocy
Copy the example configuration file to a new file.
sudo cp /var/www/grocy/config-dist.php /var/www/grocy/data/config.phpOpen the newly created
config.phpfile using a text editor.sudo nano /var/www/grocy/data/config.phpModify 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');Save and close the file.
Step 5: Install Grocy
Change to the Grocy directory.
cd /var/www/grocyInstall the required dependencies by running the following command:
sudo composer install --no-devYou should see some output in the terminal. Wait for the process to complete.
Step 6: Configure Apache
Open the Apache configuration file using a text editor.
sudo nano /usr/pkg/etc/httpd/httpd.confFind 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.soScroll 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>Save and close the file.
Step 7: Restart Apache
Restart the Apache server using the following command:
sudo /etc/rc.d/apache restart
Step 8: Access Grocy
Open your web browser and navigate to the following URL:
http://localhost/grocyYou should see the Grocy login screen. Use the default username
adminand passwordadminto log in.
Congratulations! You have successfully installed Grocy on NetBSD. You can now start using Grocy to manage your groceries, recipes, inventory, and more.