是什么导致删除文件时权限被拒绝错误? [英] What causes Permission denied errors when deleting files?

查看:106
本文介绍了是什么导致删除文件时权限被拒绝错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHP删除/var/www/main/user_resources/documents/NewFolder1/NewFolder1/noname3.php.如下所示,文件的所有者和组是phped的,它是可写的组,而Michael属于phped的组.我在Apache上使用Centos.

I am trying to delete /var/www/main/user_resources/documents/NewFolder1/NewFolder1/noname3.php using PHP. As shown below, the file's owner and group is phped, it is group writable, and Michael belongs to the phped group. I am using Centos with Apache.

[Michael@devserver NewFolder1]$ pwd
/var/www/main/user_resources/documents/NewFolder1/NewFolder1
[Michael@devserver NewFolder1]$ ls -l
total 4
-rwxrwxr-x. 1 phped phped 15 Jan  5 07:02 noname3.php
[Michael@devserver NewFolder1]$ groups Michael
Michael : Michael www phped
[Michael@devserver NewFolder1]$

我的PHP脚本是:

echo 'Current script owner: ' . get_current_user().'<br>';
echo($dirname.'</br>');
unlink($dirname);

输出如下:

Current script owner: Michael
/var/www/main/user_resources/documents/NewFolder1/NewFolder1/noname3.php

An error occurred in script '/var/www/main/application/classes/library.php' on line 477: unlink(/var/www/main/user_resources/documents/NewFolder1/NewFolder1/noname3.php): Permission denied (error no: 2)

为什么迈克尔无法删除文件?

Why can't Michael delete the file?

推荐答案

鉴于您显示的信息,您应该可以删除该文件.如果不能,则可能(肯定)没有注销用于PHP的Linux用户,然后又将其重新登录.

Given the information you show, you should be able to delete the file. If you can't, you likely (definitely) did not log the Linux user which is used for PHP out and then logged him back in.

这篇关于是什么导致删除文件时权限被拒绝错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆