是否有任何原因导致 apache 的 www-root 中的文件必须由沙箱中的 root 用户拥有?
我正在解决权限问题,如果 Apache 根文件夹中的所有文件均由用户而不“root”拥有,则可以解决该问题。由于这是一个沙盒,而且我是唯一一个在里面玩的人,所以不存在任何人为冲突。如果我做出这样的改变,我会默默地破坏一些东西吗?
我从来没有怀疑过 /home 之外的文件是否属于系统 root 用户帐户以外的任何其他用户拥有。大多数时候,更改权限确实会破坏一些东西,但是想法。哦哦。多么顽皮啊。哈哈哈。
I'm troubleshooting a permissions problem which could be solved if all files in Apache's root folder were owned by a user not "root". Since this is a sanbox and I'm the only one playing in it, there isn't any human conflict. Will I silently break something if I make this change?
I've never questioned that files outside of the /home are owned by any other user than the system's root user account. Most of the time changing permissions does indeed break things, but the thought. OHHH. How naughty. hahahah.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
恐怕有点晚了,但我刚刚发现了这个。这里的评论中有很多混乱/错误信息。在这些基本原则的范围内,你可以做任何你想做的事。我假设 httpd 用户和组(请参阅 httpd.conf 中的用户和组指令)是“apache”和“apache”;替换您自己的特定安装。
1 - 要提供的文件必须可由用户“apache”读取
2 - 目录必须可由用户“apache”搜索
3 - CGI 程序必须可由用户“apache”运行
4 - 用户“apache”不应拥有任何文件
5 - 用户“apache”不应被允许写入任何文件
6 - 组“apache”不应被允许拥有或写入任何文件
您的设置(root 拥有文件)是可以接受的,但它更有意义大多数必须修改文件(通过 ftp/etc)的人都应该 (a) 拥有这些文件,或者 (b) 属于具有文件写入权限的组。
提出一个满足所有这些标准的方案,你应该没问题。显然不允许“其他人”拥有任何不必要的权限。然而,用户“apache”位于“其他”中是正常的,因此文件通常需要其他人的读取权限。如果您想检查它,请在此处发布您的具体解决方案。
A bit late, I'm afraid, but I just found this. There's a lot of confusion/misinformation in the comments here. You can do whatever you want, within these basic principles. I'm assuming that the httpd user and group (see the User and Group directives in httpd.conf) are 'apache' and 'apache'; substitute for your own particular installation.
1 - the files to be served must be readable by user 'apache'
2 - the directories must be searchable by user 'apache'
3 - CGI programs must be runnable by user 'apache'
4 - user 'apache' should not own any files
5 - user 'apache' should not be permitted to write any files
6 - group 'apache' should not be permitted to own or write to any files
Your setup - where root owns the files - is acceptable, but it makes more sense in most setups that whoever has to modify the files (via ftp/etc) should either (a) own them, or (b) be in a group that has write permissions for the files.
Come up with a scheme that meets all these criteria, and you should be Ok. Obviously don't allow 'others' to have any permissions that aren't necessary. It's normal, however, for user 'apache' to be in 'others', so files will normally need read permissions for others. Post your specific solution here if you want it checked.
没问题。只要将组名设置为 Apache 用作组名的任何名称,您就可以将所有者更改为您的用户名。为什么?因为一周后我还是这么做了。所以,到目前为止还没有任何问题。
我在进行更改之前提出了这个问题,因为我在测试服务器上使用框架应用程序。正如我上面提到的,它安装在不同的所有者下。而且,在更改后将一个大文件夹的文件(该框架有超过 3000 个文件)恢复到原始权限实际上是不可能的。
No problem. You can change the owner to your user name as long as the group name is set to whatever Apache uses as a group name. Why? because after a week I did it anyway. So, far nothing has broken.
I asked the question before I made the change because I use a framework application on my test server. It's installed under the different owner as I mentioned above. And, its practically impossible to put a large folder of files (and this framework has over 3000 files) back to the original permissions after a change.
Apache 不会以 root 身份运行。因此 Apache 服务器没有权限写入 root 拥有的文件。如果您需要 apache 或 PHP 脚本的写入权限,则不应将 Web 内容存储为 root。
您可能不需要 apache 脚本的写访问权限,并且允许它可能会带来安全风险。通过使用 root 或通常编辑这些文件的用户可以减轻这种风险。
Apache 实例的用户名通常类似于
www-run
www-data
或apache
。Apache won't run as root. So the Apache server has no permissions to write to the files owned by root. If you need write access for apache or your PHP scripts, you shouldn't store web content as root.
You probably don't need write access for apache scripts and allowing it could pose a security risk. That risk can be mitigated by using root or whichever user usually edits those files.
The user names for an Apache instance are usually something like
www-run
www-data
orapache
.