title: PHP - Permission denied on directory created via SSH
body: <p>Under linux, using php 5.3</p>
  
  <p>If I use mkdir in a php script to create a folder, then I have full access on this folder to add files or create folder inside it.</p>
  
  <p>If I then login on the server via ssh, create a second folder, chown(recursively or not) to the exact same user:group as the one created by the php mkdir(), and chmod it to the the same exact permissions as the first folder then trying to access this folder to add a file or create a new folder inside it will throw a permission denied.</p>
  
  <p>Trying to chmod 777 does not work either. I cannot for the life of me figure out the difference between the two : </p>
  
  <pre><code>drwxr-xr-x.  2 amadeous psacln     4096  6 oct.  02:38 test
  drwxr-xr-x.  2 amadeous psacln     4096  6 oct.  02:39 testtest
  </code></pre>
  
  <p>Any idea appreciated.</p>
  
  <p><strong>EDIT AFTER COMMENTS</strong>
  The apache user is running with the user amadeous in the group psacln.
  mkdir() does create the new directory with this user and group
  A exec("whoami") returns amadeous as well.
  But still no go.</p>
  
  <p><strong>EDIT 2 AFTER COMMENTS ABOUT SELINUX BY GUIDO</strong>
  ls -Z does give different results although I don't know what to make of it :</p>
  
  <pre><code>drwxr-xr-x. amateous psacln system_u:object_r:httpd_sys_rw_content_t:s0 test
  drwxr-xr-x. amateous psacln unconfined_u:object_r:user_tmp_t:s0 testtest
  </code></pre>
  
  <p>How do I go about fixing this ?</p>
  
  <p>Thanks</p>