0

-

  • PHP Web 应用程序需要允许登录的管理员上传和删除图像到 Web 文件夹,以获取特定记录。

  • 在 MySQL 数据库中创建记录时,还会在公共服务器上创建一个文件夹 - 使用 PHP mkdir() - 来保存该特定记录的图像。

  • 同一应用程序将有多个用户,所有用户都需要向正在创建的文件夹添加和删除图像的权限。

  • 该文件夹还需要继续通过 FTP 访问。

所以我想总的来说,它需要被登录用户访问——添加、编辑、删除、查看、FTP——但公众不能访问。

我应该为此使用什么文件夹权限?

为什么?安全?可访问性?编辑能力?

谢谢。问候。

4

1 回答 1

1

使用 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 访问权限

于 2013-01-23T04:29:48.920 回答