Still confused by Permissions - linux, nginx, php-fpm
Solution 1:
The most sensible approach I came up with was this:
Look at /etc/php-fpm.d/www.conf what is the user that FPM uses. In my case it was 'apache'. Then I added this user to 'nginx' group.
And now I can control permissions in a consistent manner - user is me and I have full permission, group is 'nginx', which has read (and r+x for dirs), and it's consistent so both web content (accessed by nginx) and PHP (accessed by php-fpm) is set by the group 'nginx'.
Another good reason not to change the user or group in the php-fpm configuration is to avoid dealing with a fallout of permission issues - php-fpm created various folders/files using its previous user. And now it can't access them since no longer uses the same user. For example PHP session data (see /var/lib/php/session).
I hope this helps!
Solution 2:
Solved:
php-fpm doesn't run as the nginx user of course. It can be configured (in CentOS) in the file /etc/php-fpm.d/www.conf
. I edited its config by adding line 45:
44 ;group = nobody
45 group = webadmin
Then restarted it:
sudo /etc/init.d/php-fpm restart