Centos – Allow all users can write files/folders of user “apache”

apache-httpdcentospermissions

I run Apache 2.2.15 on CentOS 6.4

When a web local run a function and it created files/folders owned by user "apache".

I can read these files/folders via samba but i can't write/delete them.

I've tried using chmod, but it only works for that case, when this web local run again, i can't do anything with these files.

My question is : How can i change permission for user "apache" that all users can access, write, detele.. files/folder that owned by "apache" ?

Best Answer

Filesystem ACLs are going to be your best solution here.

You can set a default ACL on directories, and when a file is created in that directory, it inherits the default ACL. You can then set this default ACL to allow access to the files.

For example, if you wanted to grant all users of the group mygroup read/write access to /var/www, you can do:

setfacl -R -m group:mygroup:rw /var/www
setfacl -R -d -m group:mygroup:rw /var/www

The first line sets the ACL on all the existing files. The second line sets the default for any new files.

And while I think it's a bad idea, if you really want to allow all users full access to the files:

setfacl -R -m other::rw /var/www
setfacl -R -d -m other::rw /var/www

Note that this will require your filesystem to be mounted with ACL support. If this is not currently the case, you can do so via mount -o remount,acl /var/www (or whatever the mountpoint is). Then edit your /etc/fstab and add the acl option to the appropriate line.

Related Question