代碼(位於/var/www/html/fileio_test/io_test.php):的fopen權限被拒絕Apache服務器
<?php
$logging = <<< LOG
This is a test
LOG;
$testfile = fopen('/home/djameson/test.txt','a'); // append mode
fwrite ($testfile, $logging);
fclose($testfile);
?>
的test.txt(在/home/djameson/test.txt):
-rwxrw-r--. 1 apache apache 0 Feb 28 20:21 test.txt
錯誤:
Warning: fopen(/home/djameson/test.txt): failed to open stream: Permission denied in /var/www/html/fileio_test/io_test.php on line 7
Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/fileio_test/io_test.php on line 8
Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/html/fileio_test/io_test.php on line 9
在此去過許多天左右的文件權限的改變,增加的test.txt到不同的組,但我一直沒能寫入文件。有任何想法嗎?
sestatus的結果:
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
其它信息:
服務器上的fedora 20運行; 位於/ var/www的apache服務器
經常遇到此錯誤,並快速排除故障,請按照下列步驟操作:https://stackoverflow.com/a/36577021/2873507 –