开发者

Linux Can't Delete Files Created By www-data

I've got a web server running Ubutu 10.04 and Ap开发者_运维问答ache2 and PHP.

When I upload a file to the server through PHP, it creates it with 'rwxr-xr-x' and 'www-data www-data' as the user and group.

I've added my 'administrator' account to the 'www-data' group.

However, when I log in to my server through SSH and try and delete one of the files created, it says 'Permission Denied'? Even if I apply '0777' permission to it, I still can't delete the file.

The only way I've found that lets me delete the file is to CHOW the file to the 'administrator' account. Obviously I don't want to do this for every file uploaded, or indeed really CHMOD every file to '0777'.

What I am doing wrong here that won't let me create a file, then delete it using a different account?


The ability to delete files is not controlled by the permissions on the file but by the permissions on the containing directory.

What are the permissions and owner/group of the parent directory? Those are the permissions you will need.

Looking at the permissions listed in your comment you will either need to add group write permissions for the group www-data (Although there are security considerations to take into account here) or add yourself to the sudoers file to allow your account to perform commands as the www-data user

EDIT

The permissions that the directory is created with will be affected by your current umask setting. You can change umask to allow the creation of files with arbitrary permissions as follows :-

$old = umask(0);
mkdir(date("Y", time()), 0775)
umask($old);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜