title: PHP can't write to error log - permission denied
body: <p>In my first PHP script in many years, I'm trying to log an error:</p>
  
  <pre><code>error_log("my error message", 3, $error_log);
  </code></pre>
  
  <p>I'm getting an error in the general Apache error log:</p>
  
  <blockquote>
    <p>PHP Warning:  error_log(/var/log/apache2/my_php_errors.log): failed to open stream: Permission denied in /var/www/html/blahblah/my_script.php on line 88</p>
  </blockquote>
  
  <p>This is what I've checked and tried:</p>
  
  <ul>
  <li>Created <code>$error_log</code> with the same ownership (<code>root.adm</code>) and permissions (<code>640</code>) as the Apache error log.</li>
  <li>Changed the owner to <code>www-data</code>, which is the user PHP is running as.</li>
  <li><code>log_errors</code> is <code>On</code>.</li>
  <li><code>open_basedir</code> is not set.</li>
  <li>Using PHP 5.5.x, so safe mode does not exist.</li>
  </ul>
  
  <p>What am I missing?</p>
  
  <p><strong>Edit:</strong> It's able to write to the general Apache error log.  The mystery is why it can't write to another file in the same directory with the same ownership and permissions.</p>
  
  <p><strong>Edit 2:</strong> Another developer told me that this works on his WAMP, so it's something specific to my LAMP stack or config.</p>