I have the below code running and will give the CHMOD and CHOWN values below. But for some reason is_writable keeps failing.
我运行以下代码,并在下面给出CHMOD和CHOWN值。但由于某种原因,is_writable一直在失败。
if (!is_writeable($this->path)) {
echo 'Current script owner: ' . get_current_user();
echo '<br />';
echo $this->path;
echo '<br />';
print_r(posix_getpwuid(fileowner($this->path)));
}
The CHMOD values of the directory is 775 and the owner is User1. The output from above is
目录的CHMOD值为775,所有者为User1。上面的输出是
Current script owner: User1
path/to/directory
Array ( [name] => User1 [passwd] => x [uid] => 111 [gid] => 111 [gecos] => [dir] =>
/path/to/user [shell] => /bin/false )
The only thing that doesn't match is the owner / group of the file is 111/1 so the groups might be different but the owner is identical. Why would is_writeable fail?
唯一不匹配的是文件的所有者/组是111/1,因此组可能不同但所有者是相同的。为什么is_writeable会失败?
1 个解决方案
#1
1
Are you the owner or the webserver?
您是所有者还是网络服务器?
Everything you execute with the webserver should run as www
, _www
or www-data
(depending on the configuration; default values for different OS). So the webserver user is not in your group which causes that the file is not writeable by the webserver.
您使用Web服务器执行的所有操作都应以www,_www或www-data运行(具体取决于配置;不同操作系统的默认值)。因此,Web服务器用户不在您的组中,导致该文件无法由Web服务器写入。
(P.s.: get_current_user()
is the script owner (e.g. what you set by chown), not the script running user. Current script running user data: var_dump(posix_getpwuid(posix_getuid()));
)
(P.s。:get_current_user()是脚本所有者(例如你通过chown设置的),而不是运行用户的脚本。当前脚本运行用户数据:var_dump(posix_getpwuid(posix_getuid()));)
#1
1
Are you the owner or the webserver?
您是所有者还是网络服务器?
Everything you execute with the webserver should run as www
, _www
or www-data
(depending on the configuration; default values for different OS). So the webserver user is not in your group which causes that the file is not writeable by the webserver.
您使用Web服务器执行的所有操作都应以www,_www或www-data运行(具体取决于配置;不同操作系统的默认值)。因此,Web服务器用户不在您的组中,导致该文件无法由Web服务器写入。
(P.s.: get_current_user()
is the script owner (e.g. what you set by chown), not the script running user. Current script running user data: var_dump(posix_getpwuid(posix_getuid()));
)
(P.s。:get_current_user()是脚本所有者(例如你通过chown设置的),而不是运行用户的脚本。当前脚本运行用户数据:var_dump(posix_getpwuid(posix_getuid()));)