dtv55860 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

  • 写回答

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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?