Sunday, January 10, 2016

ubuntu - How to add write permissions to php/apache?

I've got the following scenario:
There's a folder named "uploads". It's owned by "root" and it's group is "webmasters". Permissions are set to 755.




drwxrwsr-x  2 root webmasters 4096 Mar 20 22:49 upgrade


With this setup I'm not able to create files by php in "upgrade". If I change permissions to 777 I'm able to create files in upgrade.



But the case is this:
My Apache runs as www-data. So I added the webmaster group as primary group to the user www-data.



root@mymachine: /var/www# id www-data
uid=33(www-data) gid=1002(webmasters) groups=1002(webmasters),33(www-data)



So why need I set the permissions of "upgrade" to 777? If the folder "upgrade" has the group "webmasters" and the user "www-data" has the group/is in the group webmasters and the permissions are set to 775 then all group members of webmasters should get the "7" permissions and should be able to read, write and execute.



I already restarted my machine, so I'm sure that all groups assignments are correctly recognized by the system. So what am I doing wrong?



edit://
When I change the group from "webmasters" to "www-data" I get write permissions with 775. When I switch back the group to webmasters it doesn't work. The question is why? The user www-data is in both groups - www-data and webmasters.

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...