如何在 Linux /var/www 中设置权限以允许 PHP-Apache 自动覆盖
我想允许用户通过网络应用程序上传新版本的文档。但是,当前权限未设置为允许默认情况下覆盖特定文件夹中的任何文件。有没有办法设置所有当前和未来文件的默认权限或其他设置,以自动替换为具有相同名称和路径的新文件。
编辑:我显然不是指整个 www 文件夹!只是一个子文件夹:-)
I would like to allow users to upload new versions of documents via a web app. However, the permissions are not currently set up to allow any file within the particular folder to be overwritten by default. Is there a way to set up the default permissions or other settings of all current and future files to automatically be replaced by a new file with an identical name, and path obviously.
Edit: I am obviously not referring to the entire www folder! Just a subfolder :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要回答您的问题,您只需确保 Apache 用户(通常名为 apache 或 nobody)具有对目录的写入权限。例如,chgrp -R apache /var/www/userdir && chmod -R 0775 /var/www/userdir
但是,如果该服务器可公开访问,那么这样做是一个非常糟糕的主意。相反,您需要研究类似 suPHP 的内容,它允许 Apache 以用户身份运行,并允许要覆盖的用户上传的文件。
To answer your question, you just need to make sure that the Apache user (usually named apache or nobody) has write permission to the directories. For example,
chgrp -R apache /var/www/userdir && chmod -R 0775 /var/www/userdir
However, if this server is publicly accessible, it's a very bad idea to do this. Instead, you'll want to look into something like suPHP, which allows Apache to run as the user and will allow user-uploaded files to be overwritten.