Pages

2015-06-19

Labeling files for writing with SELinux (fopen failed to write file)

Warning: fopen(newfile.txt): failed to open stream: Permission denied in /var/www/public_html/test.php on line 2
Unable to open file!

fopen gives above  error while opening stream for following code

<?php $myfile = fopen("newfile2.txt", "w") or die("Unable to open file!"); $txt = "John Doe\n"; fwrite($myfile, $txt); $txt = "Jane Doe\n"; fwrite($myfile, $txt); fclose($myfile); ?>

solution was labeling the file using following command.

chcon -t httpd_sys_rw_content_t filename


1 අදහස්:

මෙම ලිපිය කියවනකොට හිතුණු දේවල් වලින් ටිකක් මෙතන ලියලම යන්නකෝ