title: How to log errors in the same directory of the script
body: <p>What the question is about: need each <em>script</em> to log its errors in the same directory that the script is located, <strong>need to achieve this through pure configuration</strong>. By <em>script</em> I am not referring to included files, I'm referring to the files of the executing web pages.</p>
  
  <hr>
  
  <p><strong>Example 1</strong></p>
  
  <p>A syntax error of:</p>
  
  <pre><code>/var/www/html/index.php
  </code></pre>
  
  <p>Has to log to:</p>
  
  <pre><code>/var/www/html/error.log
  </code></pre>
  
  <hr>
  
  <p><strong>Example 2</strong></p>
  
  <p>A syntax error of:</p>
  
  <pre><code>/var/www/html/foobar/page.php
  </code></pre>
  
  <p>Has to log to:</p>
  
  <pre><code>/var/www/html/foobar/error.log
  </code></pre>
  
  <hr>
  
  <p>I did some configuration attempting to achieve the solution, but it doesn't work, the log file isn't being created (at least not in the directory of the <em>script</em>).</p>
  
  <p>I used <code>phpinfo()</code> to check the location of <code>php.ini</code>, it's <code>/etc/php.ini</code>. In this file I configured:</p>
  
  <pre><code>log_errors = On
  error_log = error.log
  </code></pre>
  
  <p>Then I just restarted the whole system with <code>/sbin/shutdown -h now</code> (restarted the computer), then I checked <code>phpinfo()</code> and confirmed that the changes are made.</p>
  
  <p>What I researched is that when the value of the <code>error_log</code> directive isn't an absolute path, but instead only a file name, then the location of the log file will be the same directory of the <em>script</em> which generates the error, and will have that file name.</p>
  
  <p>So, if the log file doesn't exist in the script's location, then it should be created there when an error occurs, but for some reason it's not being created. To see if it's a permission problem I manually created the log file and gave it full permissions (rwxrwxrwx), but still nothing is logged into this file when I reproduced the error. Finally I also tryed full permissions (rwxrwxrwx) for the directory containing the log file, but the problem persists.</p>
  
  <p>So what's the cause and solution?</p>
  
  <hr>
  
  <p><strong>System information:</strong> GNU/Linux CentOS with Apache.</p>
  
  <p><strong>Note:</strong> This is not a duplicate of <a href="https://stackoverflow.com/questions/18711422/error-log-in-the-same-directory-as-included-files">error_log in the same directory as included files?</a>, this question has nothing to do with included files.</p>
  
  <p><strong>Note 2:</strong> This is not a duplicate of <a href="https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them">PHP Parse/Syntax Errors; and How to solve them?</a>, the syntax error is obviously just a random example, the question is not about solving syntax errors.</p>