Wienke Posted October 2, 2006 Share Posted October 2, 2006 Whenever I use fopen or curl I always get a [i]"Warning: fopen(/tmp/test) [function.fopen]: failed to open stream: Permission denied" [/i] error. It happens when opening local files and http files. I am using php 5.1.4 and I have set safe mode to OFF and set allow_url_fopen to ON.I am using this code[code]echo $url = "/tmp/test";if ($handle = fopen($url, "r")) { $xml = stream_get_contents($handle); fclose($handle); echo $xml;} else {echo "KRAK";}[/code]I have "chmod 777"-ed the /tmp/testWhen I do a normal curl or request as the apache user I can access the files. Quote Link to comment https://forums.phpfreaks.com/topic/22758-fopen-and-curl-give-permission-denied-errors/ Share on other sites More sharing options...
Daniel0 Posted October 2, 2006 Share Posted October 2, 2006 You do not have access to open the file. Try changing the chmod value. Quote Link to comment https://forums.phpfreaks.com/topic/22758-fopen-and-curl-give-permission-denied-errors/#findComment-102402 Share on other sites More sharing options...
Wienke Posted October 3, 2006 Author Share Posted October 3, 2006 I chmod-ed all the files to 777 but it still won't work. The funny thing is when I run the script on the command line with only php e.g. "sudo - u apache php /var/www/html/test.php" it works but if I run it through the webserver it gives the error.So it could be that the problem lays within apache? Anyone ever seen this problem? Quote Link to comment https://forums.phpfreaks.com/topic/22758-fopen-and-curl-give-permission-denied-errors/#findComment-102906 Share on other sites More sharing options...
Wienke Posted October 3, 2006 Author Share Posted October 3, 2006 The problem is solved, SELinux was enabled, after disabling it everything works correctly. Quote Link to comment https://forums.phpfreaks.com/topic/22758-fopen-and-curl-give-permission-denied-errors/#findComment-102924 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.