How to Install Grocy on Elementary OS

Grocy is a self-hosted web application that can be used for managing groceries, household tasks and more. In this tutorial, we will guide you through the process of installing Grocy on Elementary OS using the Terminal.

Prerequisites

Before we start with the installation, make sure you have the following tools available:

Step 1: Update System Packages

First, we need to update our system packages. Open the Terminal emulator and run the following command:

sudo apt update && sudo apt upgrade -y

This command will update the available packages and their dependencies.

Step 2: Install Apache, PHP, MariaDB and other dependencies

Grocy is built using PHP, and its data is stored in MariaDB database. To run Grocy on your Elementary OS, you need to have Apache, PHP, and MariaDB installed. Run the following command to install all these packages and other necessary dependencies:

sudo apt install apache2 libapache2-mod-php mariadb-server php php-cli php-fpm php-gd php-mysql php-json php-mbstring php-curl php-imagick php-zip -y

This command will install all the required dependencies for Grocy.

Step 3: Install Grocy

Now, we can download and install the latest version of grocy from its official website. Use the following command to download the latest version of grocy directly into your user's home directory:

cd ~ && wget https://releases.grocy.info/latest.php -O grocy-latest.zip && unzip grocy-latest.zip -d /var/www/html/

This command will download the latest stable release of grocy and extract it to the /var/www/html/ directory, which will be the web root directory for Apache.

Step 4: Create a Database for Grocy

To create a database, first, you should log in to the MariaDB console using the following command:

sudo mysql -u root -p

Enter your MariaDB root password when prompted. Once you successfully logged in to MariaDB, then create a new database and user for Grocy using the commands below:

CREATE DATABASE grocy_db;
CREATE USER 'grocy_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON grocy_db.* TO 'grocy_user'@'localhost';
FLUSH PRIVILEGES;

Make sure to replace password with a unique and secure password.

Step 5: Configure Apache for Grocy

Now we need to configure Apache to serve Grocy. Create a new Apache virtual host configuration file grocy.conf in the /etc/apache2/sites-available/ directory using the following command:

nano /etc/apache2/sites-available/grocy.conf

Now, paste the following content in the grocy.conf file:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/html/public/
    ServerName your_domain.com
    ServerAlias www.your_domain.com

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html/public/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>

Make sure to replace ServerAdmin, ServerName, and ServerAlias values with your actual data. Save the file using CTRL + X, then Y, and hit ENTER.

Now, enable the virtual host and restart Apache with the following commands.

sudo a2ensite grocy.conf && sudo service apache2 restart

Step 6: Complete the installation

We have completed all the necessary steps to install Grocy. Finally, we need to complete the installation process by accessing the Grocy website at http://localhost/ or http://your_domain.com/ and following the prompted steps.

Congratulations! You have successfully installed Grocy on your Elementary OS machine. You can now access the Grocy website and start managing your groceries and household tasks right from your web browser.

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!