在 EC2 上使用 Apache 时,如何允许我的 apache 用户上传到用户目录?
我已经设置了一个 Amazon EC2 实例。默认情况下,我的 apache 以 apache
组的用户 apache
身份运行。
我创建了新的 ftp 用户 test
并将文件上传到 /home/test/public_html
。然后,我将虚拟主机 DocumentRoot
配置为指向我的项目,位于 /home/test/public_html
中。
当目录由用户test
拥有时,在项目中上传被拒绝:它给出权限错误。如果我将目录的所有者更改为 apache,它就可以工作。
如何赋予 apache 用户超级用户权限,以允许其在不更改目录所有者的情况下上传?
I have set up an Amazon EC2 instance. By default my apache is running as user apache
of the group apache
.
I created new ftp user test
and uploaded my files to /home/test/public_html
. I then configured the virtual host DocumentRoot
to point to my project, residing in /home/test/public_html
.
When the directory is owned by user test
, uploading in the project is denied: it gives a permission error. If I change the owner of the directory to apache
, it works.
How can give the apache
user superuser rights, to permit it to upload without changing the directory's owner?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
总是同样的问题。使用用户 ftp 上传,用户 apache 没有访问权限。
我使用文件系统扩展 acls 解决了这个问题。
可以将“默认”用户和/或组放入新生成的文件中。
您需要做什么:
示例:
首先为用户 ftp 拥有因此可以进行上传
下一步为用户 apache 设置默认值
将文件或目录放入此目录后,您将看到您对它们具有多个访问权限。但请记住,这些权利仅授予新文件,而不授予曾经存在过的文件。
使用“ls -l”时,您会在权限后面看到一个“+”,以告知有关 acl 权限的信息:
It's always same problem. Upload with user ftp and no access for user apache.
I solved that problem using filesystems extended acls.
It's possible to put a 'default' user and/or group to new generated files.
What you have to do:
Example:
First own for user ftp so uploads can be made
Next set default for user apache
After putting files or directorys to this directory you will see that you have multiple accessrights to them. But keep in mind that those rights are only given to new files not to existing once.
When using 'ls -l' you see a '+' after the permissions to inform about acl rights:
我会不惜一切代价避免让 apache 用户拥有 root 权限。
这将是一个相当严重的安全问题:正是因为服务器可能(更)容易受到攻击,所以您通常会为其创建一个特定的用户(此处为“apache”用户),您可以在其中指定权限那些服务器运行真正需要的。
如果 Apache 用户没有所有正确的权限出现问题,您应该通过将相应文件的所有权更改为 apache 用户来解决这些问题,
或者使它们对更多用户可读/可写/可执行,例如使用
I would at all cost avoid letting apache user have root privileges.
This would be quite a serious security issue: exactly because the server is potentially (more) vulnerable you normally make a specifc user for it (here the 'apache' user) where you can specify the privileges to only those that are really needed for the server run.
If there are problems with the Apache user not having all the right permissions you should solve them by changing the ownership of corresponding files to apache user,
or, by making them readable/writable/executable for more users, e.g. using