How to set permissions properly so I dont have to set permissions frequently?

Viewed 20

Currently, in developer mode, whenever there is a small change (like di:compile) then I need to set permissions like below

sudo rm -rf var/cache/* var/page_cache/* var/generation/*
sudo chown -R ubuntu:www-data var
sudo chown -R ubuntu:www-data generated
sudo chown -R ubuntu:www-data vendor
sudo rm -rf var/cache/* var/page_cache/* var/generation/*

sudo chmod -R 777 var/* pub/* generated/* vendor/*

Generally, this should be one time but I had to run this frequently, otherwise it will throw error. How can I fix this so I can do this only once ?

And in production mode, it is throwing me below error

Unable to retrieve deployment version of static files from the file system.

To fix that, I run the below command:

php bin/magento setup:static-content:deploy

But the problem is, I keep getting error many times a day and I keep running php bin/magento setup:static-content:deploy command frequently. How to make sure this wont happen?

Thanks.

I have tried setting the permissions properly but the problem is, I had to do it frequently. It should be one time right?

0 Answers
Related