我的网站在上传文件时使用所有者apache:apache创建文件,如下所示:
drwxr-xr-x 2 apache apache 4096 Aug 28 14:07 .
drwxr-xr-x 9118 apache apache 233472 Aug 28 14:07 ..
-rw-r--r-- 1 apache apache 41550 Aug 28 14:07 468075_large.jpg
-rw-r--r-- 1 apache apache 26532 Aug 28 14:07 468075_medium.jpg
-rw-r--r-- 1 apache apache 50881 Aug 28 14:07 468075_original.jpg
-rw-r--r-- 1 apache apache 4316 Aug 28 14:07 468075_small.jpg
现在,我正试图与Plesk中拥有该域的用户在同一文件夹中创建一个文件,但我的权限被拒绝了。
如何让apache和shell用户都对这些文件具有权限?
谢谢。
你必须创建一个组,并将你的Plesk和Apache用户放在其中。
并将系统的默认umask设置为002。
如果该shell用户不是apache而是在同一组中,则需要使文件夹组可写。
chown 755 .
目前,除了apache之外,它不允许任何人添加文件夹。或者,您可以尝试使用php来做fopen吗?
谢谢你的回答,但我最终决定运行一个cron作业,该作业将使用wget从网站打开一个php脚本。
这样一来,已经有权访问这些文件的apache用户就是同一个用户。我这么做基本上是因为我有很多文件,大约300GB的图像,所以我认为应用所有新权限需要很多时间。