So I have a Python Django web app that I have deployed on an internal network using Apache. Part of my web app allows the user to fill out a form - upon submit, the data is written to a json file in the home directory of my project – i.e. the data should be written to a file located in /var/www/html/project/data.json – unfortunately, I keep getting a “permission denied” error in the console.
I have tried
chmod 777 /var/www/html/project/data.json
chmod 777 /var/www/
I have also tried what this article suggested: https://fideloper.com/user-group-permissions-chmod-apache
However, that resulted in a 403 forbidden – which I had to restore permissions for /var/www/ back to its default.
I’ve been stuck on this problem for quite a few hours and I am not sure how to go about this. Python doesn’t seem to offer an option where I can
sudo write to the file. I am not sure what to do.