Jump to content


Photo

Fopen and Curl give permission denied errors


  • Please log in to reply
3 replies to this topic

#1 Wienke

Wienke
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 October 2006 - 03:36 PM

Whenever I use fopen or curl I always get a "Warning: fopen(/tmp/test) [function.fopen]: failed to open stream: Permission denied" 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
echo $url = "/tmp/test";
if ($handle = fopen($url, "r")) {
	$xml = stream_get_contents($handle);
	fclose($handle);
	echo $xml;
} else {
echo "KRAK";
}
I have "chmod 777"-ed the /tmp/test

When I do a normal curl or request as the apache user I can access the files.

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 02 October 2006 - 03:38 PM

You do not have access to open the file. Try changing the chmod value.

#3 Wienke

Wienke
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 03 October 2006 - 08:02 AM

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?

#4 Wienke

Wienke
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 03 October 2006 - 09:46 AM

The problem is solved, SELinux was enabled, after disabling it everything works correctly.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users