【问题标题】:fopen() failed to open stream: Permission denied infopen() 无法打开流:权限被拒绝
【发布时间】:2015-02-01 07:12:01
【问题描述】:

我正在尝试写入文件,但 PHP 告诉我这是被禁止的。

我尝试更改权限,将文件分配给组“apache”(根据<?php echo whoami(); ?>),但没有成功。

这是我的文件的结果:

phpversion: 5.4.16
uname: Linux

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

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)
}

你能帮帮我吗?

【问题讨论】:

    标签: php linux apache file-permissions permission-denied


    【解决方案1】:

    你设置了哪种fopen模式?读取文件足够fopen("/var/www/html/test/test.php", "r");

    【讨论】:

      【解决方案2】:

      它是 SELinux。它阻止了所有文件更改,所以我能读,但不能写。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-02
        • 2016-02-16
        • 1970-01-01
        • 2018-07-23
        • 2013-03-21
        • 2016-06-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多