开发者

php writing to file permissions issue

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)


A better choice is to change the file's group to the Apache user group, and set the file to be group-writable:

$ chgrp <apache_group> ajax_EN.json
$ chmod g+w ajax_EN.json


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜