I've been encountering an issue on a client site for the past couple of weeks where they can't upload files to a directory outside of the web root.
After looking in the error logs, it looks like PHP is spitting out errors saying the upload directory is not writable. This directory happens to be outside of the web root but there are no
open_basedir restrictions on the server.
I have a test script that executes the following code:
$path = '/var/www/vhosts/testdir'; $writable = is_writable($path) ? 'is writable' : 'is not writable'; echo "$path $writable";
When I run the script from the command line with
php test.php the directory is writable. However, when I access the page from the browser, it is not writable.
Both the web root directory and
testdir belong to the same user and group and have
755 permissions set. I've tried setting the owner of both dirs to
apache to no avail.
When I set the permissions for the upload directory to
777 it works, but obviously I don't want all my files to be readable and executable to everyone.
Distro is CentOS 6.7.
Am I missing something obvious here?