[solved] failed to open stream: Permission denied

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gorgor
Forum Newbie
Posts: 5
Joined: Sun Jul 17, 2005 10:53 am

[solved] failed to open stream: Permission denied

Post by gorgor »

I am trying to use the file command to open a remote file via http.

As a test I am just trying to hit google for now.
I get the following error.

Warning: file(http://www.google.ca) [function.file]: failed to open stream: Permission denied in /var/www/html/new.php on line 3

I can use file to open local files just file.
phpinfo.php shows allow_url_fopen=On
safe mode is off.

Not sure why it cant open the url.
Last edited by gorgor on Sun Jul 17, 2005 1:19 pm, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Are you definitely using file() and not fopen()?

If you're using fopen() the only mode that will work is 'r'.

Perhaps file_get_contents() is what you're looking for?
gorgor
Forum Newbie
Posts: 5
Joined: Sun Jul 17, 2005 10:53 am

Post by gorgor »

Thanks for the reply,
I am going:

$lines = file("http://www.google.ca");
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hmm... I can't see a reason for that then. Try adding the trailing forward slash because without it there's no path in the HTTP GET request and if that fails are you behind a proxy or firewall?
gorgor
Forum Newbie
Posts: 5
Joined: Sun Jul 17, 2005 10:53 am

Post by gorgor »

Good ideas,
trailing slash didn't help it.
box is behind a firewall but I can lynx out to the web from it no prob.

I suspect some apache security thing, its a fresh install of FC4 with the SELinux enhancement...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Does your firewall require authentication?
gorgor
Forum Newbie
Posts: 5
Joined: Sun Jul 17, 2005 10:53 am

Post by gorgor »

No, the firewall really only does incoming filtering.
gorgor
Forum Newbie
Posts: 5
Joined: Sun Jul 17, 2005 10:53 am

[solved]

Post by gorgor »

Yay!
It seems it was something to do with selinux.

I changed:
/etc/selinux/config
SELINUX=disabled

now it works fine, i will look into finer control of this selinux as it looks like you can shut it off for httpd.
Post Reply