title: PHP - readfile() failed to open stream: Permission denied
body: <p>I have the following script:
  /var/www/vhosts/default/download/index.php</p>
  
  <p>I am using readfile(); to serve files:</p>
  
  <pre><code>$path = '/data/'. $arr["$product"] .'';
  readfile($path);
  </code></pre>
  
  <p>But The following error is generated:</p>
  
  <blockquote>
    <p>[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: <a href="http://zxc.com/" rel="nofollow">http://zxc.com/</a></p>
  </blockquote>
  
  <p>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.</p>
  
  <p>What else could be the problem? Also tried to solve it with open_basedir. but no success.</p>