chgrp:不允许操作?

问题描述 投票:0回答:2

我有这么简单的代码:

      mkdir($path_to_rpi, 0755);
      chgrp($path_to_rpi, 'sambashare');

目录创建为www-data,组相同。 www-data拥有该目录,但chgrp失败了?!?

我在这里错过了什么?

php file-permissions
2个回答
2
投票

确认我的评论:

您必须是要将所有权更改为的组的成员。

http://unixhelp.ed.ac.uk/tasks/change_own.html

(死链接;使用这个:https://theory.uwinnipeg.ca/UNIXhelp/tasks/change_own.html


1
投票

我今天就碰到了这个。这是我发现的关于这个主题的最好的帖子,但是没有明确的答案,只是对各种优点的一些评论。所以这里有一个简明的总结。

--Setup--
User  : apache
Group : web
Goal  : make a new directory 'newone' owned by apache and group of web
Verify: >ls -l shows: drwxr-xr-x 2 apache web  4096  ...   newone

step 1:  apache must be a member of group web (@Flosculus answer)
check : > grep ^web /etc/group
to add: > usermod -a -G web apache

step 2: restart apache (@Andrew Mecidoo comment)
restart: > service httpd restart

step 3: make the directory
PHP: mkdir('newone', 0755);
PHP: chgrp('newone', 'web');

step 4: verify permissions
verify : > ls -l

为我工作。希望它可以帮助你。

© www.soinside.com 2019 - 2024. All rights reserved.