title: PHP is_writable() function always returns false for a writable directory
body: <p>I'm trying to install a PHP-based <a href="https://www.limesurvey.org/">software package</a> in a Red Hat 7 Amazon EC2 instance (ami-8cff51fb) that has had Apache 2.4.6 and PHP 5.4.16 installed on it using yum. The installation fails because it says a particular directory needs to be writable by the webserver with 0755 or 0775 permissions.</p>
  
  <p>The directory in question has 0775 permissions with <code>root:apache</code> ownership. I have verified that the httpd process is being run by the apache user and that the apache user is a member of the apache group.</p>
  
  <p>If I edit <code>/etc/passwd</code> to temporarily give the apache user a login shell and then <code>su</code> to that account, I am able to manually create files as the apache user within the directory using the <code>touch</code> command.</p>
  
  <p>I took a look at the source code of the installer script and identified that it's failing because PHP's <code>is_writable()</code> function is returning false for the directory in question. I created a separate test PHP script to isolate and verify the behaviour I'm seeing:</p>
  
  <pre><code>&lt;?php
    $dir = '/var/www/html/limesurvey/tmp';
    if (is_writable($dir)) {
      echo $dir, ' is writable';
    } else {
      echo $dir, ' is NOT writable';
    }
  ?&gt;
  </code></pre>
  
  <p>This outputs the NOT writable message. If I change <code>$dir</code> above to be <code>/tmp</code> then it correctly outputs that <code>/tmp</code> is writable.</p>
  
  <p>If I change the directory permissions to 0777 and/or change the ownership to <code>apache:apache</code> then PHP still reports that the directory isn't writable. I even tried creating a <code>/test</code> directory set up with the same permissions and ownership and my test script still reports it as not writable.</p>
  
  <p>I'm really at a loss as to explain this behaviour, so any ideas would be welcome!</p>
  
  <p>Thanks in advance.</p>
  
  <hr>
  
  <p>The directory listing for <code>/var/www/html/limesurvey</code> is given below. The <code>tmp</code> and <code>upload</code> directories have 0775 permissions as per Lime Survey's <a href="https://manual.limesurvey.org/Installation">installation instructions</a>. <code>test.php</code> is my test script mentioned above.</p>
  
  <pre><code>[ec2-user@ip-xx-x-x-xxx limesurvey]$ pwd
  /var/www/html/limesurvey
  [ec2-user@ip-xx-x-x-xxx limesurvey]$ ls -al
  total 80
  drwxr-xr-x. 20 root apache 4096 Mar 30 11:25 .
  drwxr-xr-x.  3 root root     23 Mar 25 14:41 ..
  drwxr-xr-x.  2 root apache   38 Mar 10 12:56 admin
  drwxr-xr-x. 16 root apache 4096 Mar 10 12:56 application
  drwxr-xr-x.  3 root apache 4096 Mar 10 12:56 docs
  drwxr-xr-x.  2 root apache 4096 Mar 10 12:56 fonts
  drwxr-xr-x. 19 root apache 4096 Mar 10 12:56 framework
  -rw-r--r--.  1 root apache  429 Mar 10 12:56 .gitattributes
  -rw-r--r--.  1 root apache  399 Mar 10 12:56 .gitignore
  -rw-r--r--.  1 root apache  296 Mar 10 12:56 .htaccess
  drwxr-xr-x.  4 root apache 4096 Mar 10 12:56 images
  -rw-r--r--.  1 root apache 6652 Mar 10 12:56 index.php
  drwxr-xr-x.  5 root apache   39 Mar 10 12:56 installer
  drwxr-xr-x. 89 root apache 4096 Mar 10 12:56 locale
  drwxrwxr-x.  2 root apache   39 Mar 25 14:41 logs
  drwxr-xr-x.  4 root apache   49 Mar 10 12:56 plugins
  -rw-r--r--.  1 root apache   61 Mar 10 12:56 README
  drwxr-xr-x.  4 root apache 4096 Mar 10 12:56 scripts
  -rw-r--r--.  1 root apache  380 Mar 10 12:56 .scrutinizer.yml
  drwxr-xr-x.  5 root apache 4096 Mar 10 12:56 styles
  drwxr-xr-x.  5 root apache 4096 Mar 10 12:56 styles-public
  drwxr-xr-x. 12 root apache 4096 Mar 10 12:56 templates
  -rw-r--r--.  1 root apache  159 Mar 30 11:11 test.php
  drwxr-xr-x.  3 root apache   20 Mar 10 12:56 themes
  drwxr-xr-x. 26 root apache 4096 Mar 10 12:56 third_party
  drwxrwxr-x.  5 root apache   80 Mar 26 13:45 tmp
  drwxrwxr-x.  6 root apache   79 Mar 10 12:57 upload
  </code></pre>
  
  <p>Running <code>namei -l /var/www/html/limesurvey/tmp</code> gives:</p>
  
  <pre><code>[ec2-user@ip-x-x-x-xxx ~]$ namei -l /var/www/html/limesurvey/tmp
  f: /var/www/html/limesurvey/tmp
  drwxr-xr-x root root   /
  drwxr-xr-x root root   var
  drwxr-xr-x root root   www
  drwxr-xr-x root root   html
  drwxr-xr-x root apache limesurvey
  drwxrwxr-x root apache tmp
  </code></pre>