title: Laravel - The stream or file failed to open stream: Permission denied
body: <p>I know this is a common problem on Laravel, but I think I'm having a different issue or else the settings aren't being updated.</p>
  
  <p>I've looked at this <a href="https://stackoverflow.com/questions/48506193/laravel-the-stream-or-file-storage-logs-laravel-log-could-not-be-opened-fail">Laravel The stream or file &quot;/storage/logs/laravel.log&quot; could not be opened: failed to open stream: Permission denied</a> and this <a href="https://stackoverflow.com/questions/30639174/how-to-set-up-file-permissions-for-laravel-5-and-others">How to set up File Permissions for Laravel 5 (and others)</a> but I still have this issue:</p>
  
  <blockquote>
    <p>The stream or file "/var/www/html/laravelwebapp/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied</p>
  </blockquote>
  
  <p>When I do this after going into the logs directory: <code>$ ls -l laravel.log</code></p>
  
  <p>I get this:</p>
  
  <p><code>-rwxrwxr-x 1 apache apache 0 Feb  8  2018 laravel.log</code></p>
  
  <p>I'm on CentOS which is why the group/user is <code>apache</code> not <code>www-data</code>. Yet even though the log is created by apache and apache is the owner and group, it can't open the stream? Does this mean Laravel is executing as another user? I'm a bit confused here, sorry :/</p>
  
  <p>I've cleared the cache using artisan and also ran <code>composer dump-autload</code> but I can't seem to progress in my application because the log doesn't get written to.</p>
  
  <p><strong>Update:</strong> My php application is running as <code>nobody</code> when I run </p>
  
  <pre><code>echo exec('whoami');
  </code></pre>
  
  <p>Is this the problem and how do I fix that?</p>