I have read the canonical answer at What permissions should my website files/folders have on a Linux webserver?
However I'm still stuck. My setup is:
- A developer user 'ade' who owns the directories and files that comprise a website
- The server is nginx with php-fpm via a socket:
- Website contains an uploads directory that must be writable by PHP when running in this configuration
- I don't want to set permissions to 777, obviously
I have created a
webadmin group and added both 'ade' and nginx to it:
$ groups ade ade : ade webadmin $ groups nginx nginx : nginx webadmin
I have set the owner of everything in the site to be me and the webadmin group:
chown ade:webadmin *
...as you can see:
drwxrwxr-x 2 ade webadmin 4096 Jul 3 13:58 logs drwxrwxr-x 5 ade webadmin 4096 Jul 4 08:35 public drwxrwxr-x 4 ade webadmin 4096 Jul 3 16:18 system drwxrwsr-x 2 ade webadmin 4096 Jul 9 16:13 uploads
However despite the permissions of uploads being 775 (rwx for both user and group) nginx and php cannot write to the folder. Only if I set it to 777 can it upload images to it.
I saw the advice about using
chmod u+w in the above canonical answer but don't understand why this is necessary.