Apache用户不能'


Apache user can't write after chown

我想允许我的apache用户可以写一个目录。我用的是centos 7。Apache用户只是apache .

从我的web浏览器中创建了一个写测试,它返回目录不可写:

/dir/webroot/write-test.php

<?php
$filename = 'test';
if (is_writable($filename)) {
    echo 'The file is writable';
} else {
    echo 'The file is not writable';
}
?>

当从浏览器访问write-test时,我得到'not writable'作为结果。

这是webroot/目录下的ls -al:

drwxr-xr-x.  6 root   root   4096 Jul 22 05:05 .
drwxr-xr-x.  4 root   root     31 Jul 21 18:06 ..
drwxr-xr-x.  2 apache apache    6 Jul 22 05:05 test
-rw-r--r--.  1 root   root    144 Jul 22 05:06 write-test.php

你可以试试$filename = '/test.txt';