使用 Web 界面上传文件时,您的上传目录需要可由 apache 用户写入。如果与文件的所有交互都将通过 Web 界面进行,您只需要担心 apache 用户,其他组将通过 Web 应用程序进行身份验证。
如果您正在创建文件夹,然后允许用户和组从您需要创建组的服务器访问文件。在这种情况下,请创建一个管理员组。
脚步:
//make the admin group
$ groupadd admin
// make the folder for uploads
$ sudo mkdir uploads
// make the apache user (apache or www-data) the owner and the group admin
$ chown apache.admin uploads
// give the folder permission using the sticky bit
// this will allow both apache and admin group to edit/add/delete in uploads
$ chmod 7752 uploads
// the sticky bit will maintain the group inside the uploads folder
// try it out
$ su apache
$ cd uploads
$ mkdir test
$ touch newFile.txt
// the new folder and new file should have admin as the group
如果没有粘性位,上传中的新文件和文件夹将归 apache 和 apache 组所有。即... chmod 775 测试
现在,当您在上传文件夹中创建新文件夹时,管理员组中的用户将拥有对它们的 ftp 访问权限