尝试使用 fopen() 时,我在运行 LAMP 堆栈的 Fedora 20 桌面上收到以下错误
警告:fopen(/var/www/html/php/documents/orders.txt):
无法打开流:
第 76 行 /var/www/html/php/processorder.php 中的权限被拒绝
我使用的代码是
$fp = fopen("$DOCUMENT_ROOT/php/documents/orders.txt", 'ab');
orders.txt具有以下权限
[root@localhost 文件]# pwd
/var/www/html/php/文档
[root@localhost 文件]# ls -l
共 4 个
-rwxrwxrwx。1 拜伦网络内容 21 年 2 月 12 日 12:33 orders.txt
我意识到这个问题已经被问过很多次了,但是没有一个解决方案对我有用。我是 Linux/Fedora 和 LAMP 的新手,所以如果错误是出于无知,我深表歉意。
编辑:似乎 SELinux 导致了这个问题,不确定如何在 SELinux 中更改设置方面克服这个问题,所以我禁用了它。
要查看是否正在执行 SELinux(我使用的是 Fedora 20),请使用/usr/sbin/sestatus。
要禁用 SELinux,请在/etc/selinux/config中配置SELINUX=disabled。