0

Every time i run setup upgrade or static-content deploy command, I need to assign permissions to var, generated, pub/static etc in Ubuntu.

Is there any permanent solution for that so every time we don't have to give permission.

surbhi agr
  • 886
  • 5
  • 22
Yogesh
  • 1,503
  • 1
  • 18
  • 37

2 Answers2

1

Another solution would be to write a shell script which performs upgrade / static deployment and sets / corrects folder permissions. That way you are only running the shell script.

As requested - something like this

deploy.sh

#!/bin/bash
echo Start
php -v
php -d memory_limit=-1 -d display_errors=on bin/magento setup:static-content:deploy -f
find ./var -type d -exec chmod 777 {} \;  
find ./pub/media -type d -exec chmod 777 {} \;  
find ./pub/static -type d -exec chmod 777 {} \; 
echo Finish

Shell example screenshot

Dominic Pixie
  • 7,520
  • 4
  • 17
  • 56
  • Please, can you share your code on how to do that, – Yogesh May 18 '19 at 16:40
  • Updated answer in response to your reply – Dominic Pixie May 18 '19 at 17:03
  • sure i will check that, thanks a lot – Yogesh May 18 '19 at 17:05
  • You can add more to that or edit it to how you work. One command per line. Accept the answer if it works out for you. Forgot to mention make sure that the shell script has execute permission. – Dominic Pixie May 18 '19 at 17:50
  • this is very bad approach, do not run any commands as root, you dont have to change permissions, just updated the owner - chown -R user:user * – MagenX May 18 '19 at 18:32
  • I didn't say to run as root. That was a rough and ready example simply showing a screenshot of the shell script i put together running. Besides it's in a docker container within a dev box. No magento install was harmed in the making of this screenshot. – Dominic Pixie May 18 '19 at 18:40
  • @Dominic Xigen your solution is good but it's not what i am looking for it done ultimately what I do manually via CLI, +1 for this – Yogesh May 19 '19 at 12:39
0

Pls refer devdocs regarding two user here:

the light
  • 718
  • 1
  • 5
  • 15
  • I have referred that and tried to apply solution but facing the same issue, please give a proper answer with step – Yogesh May 18 '19 at 16:38