I had been trying to install Grocy in my Debian VPS1 for a week with no success. After several failed attempts, today I have finally made it.

In the beginning I followed the guide in the documentation and the guide pined in Reddit (link), but it did not work: some HTTP 500 Error or something like that. Then I made my own custom Nginx server configuration, it did not work neither. Then moved the files to different directories, changed their ownership, installed php8.1, etc., but nothing seemed to work.

The best result I achieved was being able to login, just to face a dashboard seeming not to recognize the CSS styling. A similar situation had been reported in Reddit a few days ago (link).

But then, out of nowhere…

Today I got the idea to be certain that the problem was in my VPS. So I installed php8.1 in my PC, downloaded Grocy, and run the app with php -S 127.0.0.1:8000 from grocy/public. It worked like a charm.

So I tried by first removing php in my VPS and then installing php8.1 from scratch, and it worked! The following are the exact steps I did:

Purge php7.4 and install php8.1

Remove the php version currently installed, because mine was 7.4

1
apt remove --purge php*

Update and upgrade the system

1
2
apt update
apt upgrade

Installed some other packages2 to add the php8.1 repository to the list

1
apt install ca-certificates apt-transport-https software-properties-common curl lsb-release wget unzip -y

Then use this script to set up the php8.1 repository

1
curl -sSL https://packages.sury.org/php/README.txt | bash -x

Update and upgrade the system

1
2
apt update
apt upgrade

Install php8.1 and other dependencies for Grocy

1
apt install php8.1 php8.1-fpm php8.1-cli php8.1-gd php8.1-intl sqlite3 php8.1-sqlite3 php8.1-mbstring -y

Start the php8.1 process

1
systemctl start php8.1-fpm

Download Grocy and set the Nginx server

Make the folder where Grocy is gonna live, and move to it

1
2
mkdir /var/www/grocy
cd /var/www/grocy

Download the last version of Grocy, and unpack it

1
2
3
wget https://releases.grocy.info/latest
unzip latest
rm latest

Copy the config.php file to the data folder

1
cp config-dist.php data/config.php

Note: Normally you would edit the config.php file as described in the documentation and in its internal comments. In my case the Grocy instance is going to be on the subdomain grocy.website.org of my VPS. Therefore, I do not need to edit anything in config.php.

Change the ownership of the files to the user and group www-data (which should exist by default in your system).

1
chown -R www-data:www-data /var/www/grocy

Edit/create the file /etc/nginx/conf.d/fastcgi_params and fill it with the following information

1
2
3
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; 

Finally set the Nginx server. In the file /etc/nginx/sites-available/grocy write the following

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
server {
	listen 80 ;
	listen [::]:80 ;
		
	root /var/www/grocy/public;
	
	index index.html index.php;
	server_name grocy.website.org www.grocy.website.org;

	location / {
		try_files $uri $uri/ /index.php;
	}
     
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
	}
}

Of course you must change the server_name directives to your server.

Then create the link to the sites enabled folder

1
ln -s /etc/nginx/sites-available/grocy /etc/nginx/sites-enabled

and restart Nginx

1
systemctl restart nginx.service

If you go to the server_name address it should be there.

Conclusions

Following those exact steps it worked to me, and I did it twice from scratch to check it wasn’t just luck.

Finally, if you are using Certbot to encrypt the traffic to your Nginx server, do

1
certbot --nginx

Do not hesitate to contact me in case you find something wrong here, or have any question. Have in mind that I am not an expert on the subject, so anything too technical may be difficult to me.

Footnotes


  1. Virtual Private Server. I am currently using 1984↩︎

  2. In this post it is suggested to install them to add the php8.1 repo. ↩︎