ds15812330851 2014-12-03 16:16
浏览 226
已采纳

fopen()无法打开流:权限被拒绝

I'm trying to write to file, but PHP tells me that it's forbidden.

I tried to change permissions, assigned files to group 'apache' (according to <?php echo whoami(); ?>), but it didn't work.

Here is result of my file:

phpversion: 5.4.16
uname: Linux

exists // echo file_exists($file) ? ' exists' : ' does not exist', "
";
is readable // echo is_readable($file) ? ' is readable' : ' is NOT readable', "
";
is NOT writable // echo is_writable($file) ? ' is writable' : ' is NOT writable', "
";

Warning:  fopen(system/cache/cache.currency.1417623063): failed to open stream: Permission denied in /var/www/html/test/test.php on line 23
last error: array(4) {
  ["type"]=>
  int(2)
  ["message"]=>
  string(87) "fopen(system/cache/cache.currency.1417623063): failed to open stream: Permission denied"
  ["file"]=>
  string(30) "/var/www/html/test/test.php"
  ["line"]=>
  int(23)
}

Can you help me, please?

  • 写回答

2条回答 默认 最新

  • duanqiao1880 2014-12-06 17:08
    关注

    It was SELinux. It blocked all file changes, so I was able to read, but not write.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog