我如何弄清楚用户和用户是什么? Apache 组正在运行?
在 DreamHost 共享主机上,我正在设置 htpasswd,但 Apache 无权读取该文件。我如何授予它权限?我想更改 .htpasswd
文件的所有者或组,而不是授予它不安全的权限。我认为我无权访问 httpd.conf
文件,因此我无法使用此方法 查找 Apache 运行时的用户。另外,运行 top
或 ps aux
仅显示我正在运行的进程,但不显示 apache 进程。
根据 cat /etc/passwd
和 cat /etc/group
的输出,我猜测它是 www-data
。
好吧,我按照Dreamhost 上的密码保护目录的说明进行操作。它生成了一个包含 .htpasswd
文件的目录,该文件具有组 dhapache
和权限 440
。它还在我的组下放置了一个 .htaccess
文件。由于某种原因,当我尝试 chgrp dhapache test_file.txt
时,我得到 chgrp: moving group of 'test_file.txt': Operation not allowed
。因此,我只是将 DreamHost 生成的 .htpasswd
文件移动到我想要的位置,并编辑了它生成的 .htaccess
文件,尽管有警告。
On DreamHost shared hosting, I'm setting up htpasswd, but Apache does not have permission to read the file. How do I give it permission? I want to either change the owner or group of the .htpasswd
file instead of giving it insecure permissions. I don't think I have access to the httpd.conf
file, so I can't use this method to find what user Apache runs as. Also, running top
or ps aux
only shows the processes I'm running but doesn't show the apache process.
Based on the output from cat /etc/passwd
and cat /etc/group
, I'm guessing it's www-data
.
Well, I followed the instructions for Password-protecting directories on Dreamhost. It generated a directory with a .htpasswd
file with the group dhapache
and permissions 440
. It also put a .htaccess
file in there with under my group. For some reason, when I try chgrp dhapache test_file.txt
I get chgrp: changing group of 'test_file.txt': Operation not permitted
. So, I just moved the .htpasswd
file that DreamHost generated to where I wanted it and edited the .htaccess
file it generated, despite its warnings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,您不需要访问 httpd.conf:
应该会产生您想要的结果
Actually, you don't need access to httpd.conf:
should yield what You want
我遇到了一些问题,导致我找到了另一种解决方案。但它只有在您有权访问配置文件时才有效。
我们实际上可以在
\etc\apache2\envars
文件中检查用户和组。这是 Apache 设置环境变量并在应用程序中使用它的地方。查找这两行:
注意这只是设置环境变量。实际设置 apache 以用户/组的身份运行实际上位于
\etc\apache2\apache2.conf
文件的位置可能与我不同,但您应该明白。
I was having some issue that leads me to another solution. But it only works when you have access to the configuration file
We can actually check the user and group in
\etc\apache2\envars
file. This is where Apache set the environments var and use it across application.Look for this two lines:
Note this is just setting environment variables. The actual setting the apache to run as what user/group is actually in the
\etc\apache2\apache2.conf
The location of the files might me different but you should get the idea.