title: PHP fopen($file, "w") permission denied
body: <p>I have a problem with a php script on my webserver (Apache/2.4.10 on Raspbian), I can't generate a new file on it. I have tried chmod 777 (which is really bad practice) and it still didn't work. I have been struggling with this for a few days and even after extensive research I couldn't find a solution to this problem. Below is my code and the error messages generated by it:</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors',1);
  error_reporting(E_ALL);
  $newwish = fopen("newfile.txt", "w+");
  $txt = "LALALA";
  fwrite($newwish, $txt);
  fclose($newwish);
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>Warning: fopen(newfile.txt): failed to open stream: Permission denied
    in /var/www/html/handlers/wish.php on line 4</p>
    
    <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in
    /var/www/html/handlers/wish.php on line 6</p>
    
    <p>Warning: fclose() expects parameter 1 to be resource, boolean given in
    /var/www/html/handlers/wish.php on line 7</p>
  </blockquote>