2012-11-18 21:03
浏览 31

如何让/ etc / hosts为php而不是用户写入

I've been trying to set this, but I'm stacked. I don't know how to set /etc/hosts writable for php, but not for user.

If I set chmod 060 /etc/hosts and chown www-data:www-data /etc/hosts, then php is unable to write (I supposed that php's group is www-data). If I set chmod 660 /etc/hosts it's working for php but also for user.

Is this possible?

EDIT: I found out that my user was in www-data group, so that was why applying 460 on /etc/hosts didn't work

图片转代码服务由CSDN问答提供 功能建议

我一直试图设置它,但我已经堆积了。 我不知道如何为php设置/ etc / hosts可写,但不能为用户设置。

如果我设置 chmod 060 / etc / hosts chown www-data:www-data / etc / hosts ,那么php 无法写(我认为php的组是www-data)。 如果我设置 chmod 660 / etc / hosts ,它适用于php,也适用于用户。


编辑: 我发现我的用户在www-data组中,这就是为什么在/ etc / hosts上应用460无法正常工作< / p>

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzhang1926 2012-11-18 21:45

    What you are doing is a terrible idea -- the hosts file should never be writable by any user other than root.

    Nevertheless, the correct permissions to set to accomplish this would be:

    chown www-data:www-data /etc/hosts
    chmod 644 /etc/hosts
    点赞 评论

相关推荐 更多相似问题