我如何弄清楚用户和用户是什么? Apache 组正在运行?

发布于 2024-10-05 14:49:59 字数 925 浏览 0 评论 0原文

在 DreamHost 共享主机上,我正在设置 htpasswd,但 Apache 无权读取该文件。我如何授予它权限?我想更改 .htpasswd 文件的所有者或组,而不是授予它不安全的权限。我认为我无权访问 httpd.conf 文件,因此我无法使用此方法 查找 Apache 运行时的用户。另外,运行 topps aux 仅显示我正在运行的进程,但不显示 apache 进程。

根据 cat /etc/passwdcat /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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

偷得浮生 2024-10-12 14:49:59

实际上,您不需要访问 httpd.conf:

ps aux | grep apache2
groups apache_user

应该会产生您想要的结果

Actually, you don't need access to httpd.conf:

ps aux | grep apache2
groups apache_user

should yield what You want

高跟鞋的旋律 2024-10-12 14:49:59

我遇到了一些问题,导致我找到了另一种解决方案。但它只有在您有权访问配置文件时才有效。

我们实际上可以在 \etc\apache2\envars 文件中检查用户和组。这是 Apache 设置环境变量并在应用程序中使用它的地方。

查找这两行:

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

注意这只是设置环境变量。实际设置 apache 以用户/组的身份运行实际上位于 \etc\apache2\apache2.conf

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

文件的位置可能与我不同,但您应该明白。

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:

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

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

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

The location of the files might me different but you should get the idea.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文