php写入文件权限问题
当 php-script 尝试写入文件时:
-rwxr-xr-x. 1 eugene_val eugene_val 8033 Sep 10 10:47 ajax_EN.json
我收到错误:
fopen(ajax_EN.json): failed to open stream: Permission denied
我想知道考虑到安全性,什么是适当的解决方案。 我能想到的选项是:
1)将此文件chown到apache用户并将其chmod到700
2)将apache添加到文件所有者组
3)使用suPHP和likes(我不希望这样做,因为性能)打)
When php-script is trying to write to a file:
-rwxr-xr-x. 1 eugene_val eugene_val 8033 Sep 10 10:47 ajax_EN.json
I get an error:
fopen(ajax_EN.json): failed to open stream: Permission denied
I wonder what could be an appropriate solution to it taking security into consideration.
The options I could think of are:
1) chown this file to apache user and chmod it to 700
2) add apache to a group of the file-owner
3) use suPHP and likes(which I would not like to because of the performance hit)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更好的选择是将文件的组更改为 Apache 用户组,并将文件设置为组可写:
A better choice is to change the file's group to the Apache user group, and set the file to be group-writable:
该文件的路径的权限也很重要。即使您对文件进行 chmod 777,如果尝试读取该文件的用户没有该路径的读取权限,他们仍然无法读取该文件。
The permissions of the path for this file also matter. Even if you chmod 777 the file, if the user trying to read it doesn't have read permissions for the path, they still won't be able to read the file.