php 警告:touch():Utime 失败:权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22568289/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Warning: touch(): Utime failed: Permission denied
提问by 6paq
I am writing the session to a temporary file as follows:
我正在将会话写入临时文件,如下所示:
if ($_SESSION['user_login_status'] == 1)
{
touch("tmp/access-" . session_id());
}
I have the following permissions set on tmp just to test it is working (I will modify permissions to be more restrictive as I test):
我在 tmp 上设置了以下权限只是为了测试它是否正常工作(我将在测试时修改权限以使其更具限制性):
drwxrwxrwx+
I receive the following error:
我收到以下错误:
Warning: touch(): Utime failed: Permission denied
Any thoughts? Everything I have googled thus far says check the permissions (done) or is related to a wordpress error which I am not running. Thanks!
有什么想法吗?到目前为止我用谷歌搜索的所有内容都说检查权限(完成)或与我没有运行的 wordpress 错误有关。谢谢!
采纳答案by Hamman Samuel
I had the same error message show up (but a different code snippet). What solved it for me was to change the owner for the file, i.e. chown uname:uname filename
.
我显示了相同的错误消息(但代码片段不同)。为我解决的是更改文件的所有者,即chown uname:uname filename
.
回答by Reinoud van Santen
It seems that the permissions on the directory are not the problem, rather the "access-" . session_id() seems to already exist and it's permissions are so that the PHP process can't change it's Utime. Check if the file "access-" . session_id() exist, if so remove it and run the script. If you do not receive an error check if the file "access-" . session_id() was created and what it's permissions are. If they are not correct try to chmod the file directly after creating it with touch.
似乎目录的权限不是问题,而是 "access-" 。session_id() 似乎已经存在,它的权限是 PHP 进程无法更改它的 Utime。检查文件“访问-”。session_id() 存在,如果存在,请删除它并运行脚本。如果您没有收到错误检查文件“access-”。session_id() 已创建以及它的权限是什么。如果它们不正确,请尝试在使用 touch 创建文件后直接 chmod 文件。
回答by Chris Stryczynski
I ran into the error and just removed the underlying files and the error went away...
我遇到了错误,只是删除了底层文件,错误就消失了......