PHP:fopen()权限被拒绝 [英] PHP: fopen() Permission denied
本文介绍了PHP:fopen()权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对这段代码感到困惑:
I am confused with this code:
test.php:
fopen('test.txt','a+');
当我执行它时,我得到一个错误:
when I execute it, I get an error:
Warning: fopen(test.txt): failed to open stream:
Permission denied in /var/www/html/yuelu3/mobile/text.php on line 2
test.txt:
-rwxrwxrwx. 1 jt jt 87 10月 7 20:58 test.txt
问题出在哪里?
非常感谢!我发现了问题,我使用FC13,因为SELinux的保护,某些动作被拒绝了.所以,我只需要摆脱保护.
Thanks a lot!I have found the problem,I use FC13,because of the protect of SELinux,some action is denied.So, I just need to get rid of the protect.
推荐答案
此问题也可能是由于启用了SELinux导致的.可以使用以下方法解决:
This issue can also be a result of having SELinux enabled. This can be solved using:
chown -R apache:apache /var/www/html/directory_to_write
chcon -R -t httpd_sys_content_t /var/www/html/directory_to_write
chcon -R -t httpd_sys_rw_content_t /var/www/html/directory_to_write
这篇关于PHP:fopen()权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文