0
votes

Server is Cento7 running Nginx & PHP. I run Nginx and PHP-FPM as user nginx. nginx is a member of a group called webmasters.

My website is at /var/www/production/site/

Owner of /var/www/production/site/ is other_user:webmasters. Permissions are 0775 These are both applied to all subfolders.

A php script calls file_put_contents() but gets 'permission denied' as it attempts to write to a subfolder.

If I change the owner of /var/www/production/site/ to nginx:webmasters I do not get permission denied.

SELinux is disabled.

So as a member of a group with RWX it cannot write. Any suggestions?

1
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Web Applications Stack Exchange, Webmaster Stack Exchange or Unix & Linux Stack Exchange would be a better place to ask.jww
I would try to login to the server and su to the user nginx (su - nginx) and test if this user can change and write in the shell to that directory, perhaps you see there some problems (e.g. parent folder permissions). And have look with ps if the PHP-FPM really runs as nginx.data cosmos

1 Answers

1
votes

If you want a member of the group to be able to write to it, it will need to be 775. 755 is rwxr-xr-x, which means that owner can do anything, but the group can read but not write to it. 775 is rwxrwxr-x which just stops anyone outside user or group writing to it.