[英]fopen() gives permission denied error - despite chmod 777
I get the following error on my Fedora 20 desktop running the LAMP stack when trying to use fopen() 尝试使用fopen()时,我在运行LAMP堆栈的Fedora 20桌面上出现以下错误
Warning: fopen(/var/www/html/php/documents/orders.txt):
警告:fopen(/var/www/html/php/documents/orders.txt):
failed to open stream:
无法打开流:
Permission denied in /var/www/html/php/processorder.php on line 76
第76行/var/www/html/php/processorder.php中的权限被拒绝
The code I used is 我用的代码是
$fp = fopen("$DOCUMENT_ROOT/php/documents/orders.txt", 'ab');
orders.txt has the following permissions orders.txt具有以下权限
[root@localhost documents]# pwd
[root @ localhost documents] #pwd
/var/www/html/php/documents
在/ var / www / html等/ PHP /文档
[root@localhost documents]# ls -l
[root @ localhost documents] #ls -l
total 4
总共4
-rwxrwxrwx.
-rwxrwxrwx。 1 byron web-content 12 Feb 21 12:33 orders.txt
1 byron web-content 12 Feb 21 12:33 orders.txt
I realise this question has been asked a number of times, but none of the solutions have worked for me. 我意识到这个问题已被多次询问,但没有一个解决方案对我有用。 I am new to Linux/Fedora and to LAMP so I apologise if the error is borne out of ignorance.
我是Linux / Fedora和LAMP的新手,所以如果错误是出于无知,我会道歉。
Edit: Seems like SELinux was causing the problem, not sure how to overcome this in terms of changing settings in SELinux, so I disabled it. 编辑:似乎SELinux导致了问题,不知道如何在更改SELinux中的设置方面克服这个问题,所以我禁用了它。
To see whether SELinux is being enforced (I'm using Fedora 20) use /usr/sbin/sestatus . 要查看SELinux是否正在执行(我正在使用Fedora 20),请使用/ usr / sbin / sestatus 。
To disable SELinux, configure SELINUX=disabled in /etc/selinux/config . 要禁用SELinux,请在/ etc / selinux / config中配置SELINUX = disabled 。
Seems like SELinux was causing the problem, not sure how to overcome this in terms of changing settings in SELinux, so I disabled it. 似乎SELinux导致了这个问题,不知道如何在更改SELinux中的设置方面克服这个问题,所以我禁用了它。
To see whether SELinux is being enforced (I'm using Fedora 20) use /usr/sbin/sestatus. 要查看SELinux是否正在执行(我正在使用Fedora 20),请使用/ usr / sbin / sestatus。
To disable SELinux, configure SELINUX=disabled in /etc/selinux/config. 要禁用SELinux,请在/ etc / selinux / config中配置SELINUX = disabled。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.