Hi
I have written a simple php script to read a url.
<?php
$myfile = file('http://google.com');
foreach ( $myfile as $vals){
print "$vals";
}
?>
I got an error: failed to open stream: Permission denied.
This works on my windows box, but does not work on Linux.
When I type in on a command line like "php -f filename". it works.
Any idea why this does not work?
What configuration do I have change to make this work?
sy
file($url): failed to open stream: Permission denied
Moderator: General Moderators
Either Apache (usually www-data), or the file/folder does not have the right permissions set.
www.google.com
www.google.com
Different PHP settings, probably. Is allow_url_fopen enabled on both php settings?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
open($url) permission denied
yes, allow_url_fopen is "on".scottayy wrote:Different PHP settings, probably. Is allow_url_fopen enabled on both php settings?
file($url): failed to open stream: Permission denied
[quote="Zoxive"]Either Apache (usually www-data), or the file/folder does not have the right permissions set.
Would you please tell me a bit more specifically about www-data?
Do you mean by that some of my apache directives does not allow reading url?
The script tries to read the url 'http://google.com' using the 'file' function. As long as google's web
page has read permission, it should be fine, isn't it?
I can read the file if the absolute path is specified on my local machine. For example,
file('/var/www/index.html'); // this works, but
file('http://localhost/index.html'); // failed to open stream: permission denied.
// web root directory is defined "/var/www'
file('http://google.com'); // failed to open stream: permission denied.
Would you please tell me a bit more specifically about www-data?
Do you mean by that some of my apache directives does not allow reading url?
The script tries to read the url 'http://google.com' using the 'file' function. As long as google's web
page has read permission, it should be fine, isn't it?
I can read the file if the absolute path is specified on my local machine. For example,
file('/var/www/index.html'); // this works, but
file('http://localhost/index.html'); // failed to open stream: permission denied.
// web root directory is defined "/var/www'
file('http://google.com'); // failed to open stream: permission denied.
file($url): failed to open stream: Permission denied
Linux firewall blocked it.
How to fix:
In Fedora 5, select Permissive or Disable from System->Administration->Security
Level and Firewall->SELinux
It does work.
How to fix:
In Fedora 5, select Permissive or Disable from System->Administration->Security
Level and Firewall->SELinux
It does work.