I have a vm where I run ubuntu 18.04 , Apache 2 and Magento 2.3 every thing works fine but I think I'm doing something wrong with my permissions.

So I have added to user 'dev' to the www-data group (dev is also the sudo user that I use to login )

but when I do

sudo chown -R  dev:www-data /var/www 

My Magento site stops working because it complains it has not access to the files. but when I run

sudo chown -R  www-data:www-data /var/www 

All work fine again and I don't understand why, because the user dev is added to the www-data group so it should have the wright permissions.

or should I run

sudo chown -R dev:www-data /var 

I don't know?????

1 Answer 1


Set Magento permission :-

sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
sudo chown -R :www-data .
sudo chmod u+x bin/magento
sudo chmod -R 777 pub var app/etc setup generated

After follow magento step you need to give permission to these folder :-

sudo chmod -R 0777 var/ generated/code/ pub/static
  • Yes i have tried that but the moment i run bin/magento setup upgrade. the site goes blank unit i run chown -R www-data:www-data .
    – BigJonna
    Sep 8, 2021 at 8:06
  • after setup upgrade you nedd to set permission this :- sudo chmod -R 0777 var/ generated/code/ pub/static Sep 8, 2021 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.