title: SELinux influences "failed to open stream: Permission denied” PHP error
body: <p>Yesterday I've spent 5 hours straight discovering a seemingly unreasonable error "failed to open stream. permission denied", which was occuring after any operations of writing to file system: fopen (with "w" and "a" flags), move_uploaded_file, file_put_contents.</p>
  
  <p>I've rechecked many times directories owner (user and group - chown, chgrp), have change folder attributes to unsecure 777 (rwx with <code>chmod</code>), but it has no effect. I even reinstalled an Apache and PHP, but still was facing the same error.</p>
  
  <p>As it is appeared after hours of reading various documentation the origin of error was SELinux restrictions automatically applied for Apache service httpd. I've simply turned off the SELinux by editing <code>/etc/selinux/config</code> file on my Fedora (release 20) via changing line:</p>
  
  <pre><code>SELINUX=enforcing
  </code></pre>
  
  <p>to</p>
  
  <pre><code>SELINUX=disabled
  </code></pre>
  
  <p>I restarted my computer and that annoying error had finally dissapeared.</p>
  
  <p>I have to notice that all the questions at Stack Overflow regarding the issue of "permission denied" on LAMP environment were touching only the folder permission concerns which was not the case in my case.</p>
  
  <ol>
  <li><p>(<em>practical</em>) How can I grant Apache httpd service write-delete-update permissions on directory without totally disabling SELinux?</p></li>
  <li><p>(<em>theoretical</em>) What is the SELinux? What it is intended for? Why (for what reason) it was created? Why should I use it? Is there a reason to keep SElinux enabled on local dev machine?</p></li>
  </ol>
  
  <p><em>solely to moderators of the resource: I know that this issue covers more administrating than actual programming, but I'm sure it affects developers in much more severe way than say novice administrators, so choosing between SuperUser and StackOverflow I took the latter. However it is up to you whether to move the question at SuperUser or keep at this place.</em></p>