permissions CLI vs apache

Notice: This thread is very old.
tivvit
Member | 36
+
0
-

Hi,

I have problem with running CLI commands in the app, because Nette called from the browser runs under user _www in group _www. This call creates cache files with permissions -rw-r--r-- so it doesn't matter that my user is also in the group _www.
So the problem is when I run tests or any other command like php www/index.php orm:schema:update under another user than _www I end up with Permission denied, so I run those commands with sudo which sucks and it chowns temp files to another user so I have to fix it then :/

How you guys solve this issue?

Filip Procházka
Moderator | 4668
+
0
-

When you're running the command, you're probably doing that using your own user, but the app was compiled (and the cache directory created) under _www user. I consider this wrong.

  • either do sudo su _www and then run the command
  • or have a user specially for the app, that the php is running under and that you can login to
Aurielle
Member | 1281
+
0
-

I personally found this StackOverflow thread as a good solution to my problems.

Tl;dr you set up setgid bit and default umask so all files always have www-data's (or the webserver's) group and have group permissions making them at least readable for the webserver.