unable to create a file in php
- Fedora 23 x64
- php 5.6.17
Permissions are as open as I know how to make them (777). Yes, I know this isn’t safe. Once I figure out the problem, I will make them safe.
# ls -lhd /srv/www/html/sigs/ drwxrwsrwx. 2 root root 4.0K Apr 13 19:37 /srv/www/html/sigs/
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $file = '/srv/www/html/sigs/file.txt'; $mf = fopen($file, 'w'); fwrite($mf, 'hi'); fclose($mf); echo $file; ?>
Warning: fopen(/srv/www/html/sigs/file.txt): failed to open stream: Permission denied in /var/www/html/trial.php on line 6 Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/trial.php on line 7 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/html/trial.php on line 8 /srv/www/html/sigs/file.txt
I am pulling out my hair here :)
I have tried setting the directory permissions to 777, 775, 755
I have tried setting the user and group to apache
If I write to the /tmp directory, I don’t get any errors, but I also don’t get a file.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.