File ownership of generated files

I have 2 php applications running on my server and the files in these applications are owned by two users (user1 and user2)

File ownership looks like this: user-www and data2: www-data. I am assigning www-data as a group so my php application can write files easily when permission is set to 775. So I set all file permissions to 755 and 775 (for files to be written).

So far so good, the only problem is that when my php app created the file, it sets the ownership of www-data www-data, which I don't want. I want php to set permission to iether user1: www-data or user2: www-data depending on which application it is.

I am using Nginx 1.6.3 and php 5.5.24 with php-fpm.

+3


source to share


1 answer


You can set the setgid flag to the directory where the files are saved.

setgid will cause files saved in this directory to belong to the same group as the directory itself



chmod g+s directoryname

      

0


source







All Articles