Sinan Sinan - 1 year ago 242
PHP Question

PHP - readfile() failed to open stream: Permission denied

I have the following script:
/var/www/vhosts/default/download/index.php

I am using readfile(); to serve files:

$path = '/data/'. $arr["$product"] .'';
readfile($path);


But The following error is generated:


[error] [client xx] PHP Warning: readfile(/data/xxx.iso): failed to open stream: Permission denied in /var/www/vhosts/default/download/index.php on line 33, referer: http://zxc.com/


I thought it is caused by permissions, therefor I gave 777 to the /data directory and 777 to the files in /data, but didn't solve the problem. Then I changed the owner of the directory + files to apache, but also didn't solve it.

What else could be the problem? Also tried to solve it with open_basedir. but no success.

Answer Source

I found the problem. It seems SELinux was enabled. Disabled SELinux and it is working now.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download