Im Working on an application that requires several users to have access to a directory called previews.
So I set the primary group of each user to be www
When the files have a group of www
the application works without any issues.
The problem is that the files are created through an http request, meaning that the apache
user is creating the file.
when i run
id apache
i get uid=48(apache) gid=501(www) groups=501(www),48(apache)
but the file's owner and group is apache apache
i can't figure out how to get apache to create files with owner and group as apache www
Thanks in advance. I have spent many days trying to figure this out.
setgid
In the directory where the files are created, you can set that directory to the group you want and set the setgid bit, so all the files in that directory have the same group.
If the directory doesn’t have the group you want, use chown.
chown username:www directory/
ls -lld directory/ should have “username www”.
chmod g+s directory/
ls -lld should show an “s” where the group “x” was, drwxr-sr-...
cd directory/
touch testFile
ls -ll testFile
The file testFile should be “username www”.
I don’t know the rules about linking information here, but google “oracle setgid” to find a good document.