0

When running a script I get the following error: 'The folder "x" is not writable.' Folder's permissions are 755. Folder ownership is user:user. PHP runs as apache.

When changing group ownership of folder to apache it works, but it's not very practical.

Ideal would be if any admin could upload a script which can be executed without problems.

What is the commonly accepted/best solution for it?

P.S. I run standard clean CentOS 6.x

2
  • From other answers I've found that there can be also www-data (how does it work/it's relationship with apache and users?) owner, and other option is a module that runs each child process as a different user called mpm-itk. This allows to run each vhost under a separate userid. Can anyone share pros and cons of each set up, and suggest the most commonly used and secure approach?
    – James S.
    Sep 18, 2013 at 3:49
  • change the ownership for directory to www-data:www-data as www-data is apache user in CentOS. Sep 18, 2013 at 3:59

1 Answer 1

0

775 breaks down like this:

first 7  - user read/write/execute
second 7 - group read/write/execute
last 5   - others read/execute

In order for the apache user to be able to write to the folder, it will need write permission, so either it will need to have group perms, ownership of the folder or have full read/write/execute to everyone on the server.

4
  • I know the concept, but how do I implement it? I don't want add every user to apache group, and I don't want make every folder owned by Apache. Does it mean I have to run php not as Apache?
    – James S.
    Sep 18, 2013 at 3:26
  • You only need to make that folder owner, not the entire tree (which is highly discouraged). Plan B is to set the permissions as 777, which might not be a good idea if you have users on that server that you don't want access. Plan C is to use ACLs instead of Linux permissions, if CentOS 6.x supports them. Sep 18, 2013 at 4:13
  • Thanks, I'll research on ACL. Is there a way to set group ownership for all folders uploaded by admin group users to apache?
    – James S.
    Sep 18, 2013 at 5:00
  • Try using a sticky bit in chmod (chmod g+s foldername). Sep 19, 2013 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .