Linux cannot delete files created by www-data

I have a web server with Ubutu 10.04 and Apache2 and PHP.

When I upload a file to the server via PHP, it creates it using "rwxr-xr-x" and "www-data www-data" as a user and group.

I added the administrator account to the www-data group.

However, when I log in to my server via SSH and try to delete one of the created files, it says: "Permission Denied"? Even if I apply the resolution “0777” to it, I still cannot delete the file.

The only way I found that allows me to delete the file is to use the CHOW file in the "administrator" account. Obviously, I don’t want to do this for every file uploaded, or really CHMOD for every file up to "0777".

What am I doing wrong here that will not allow me to create a file and then delete it using a different account?

+3
source share
1 answer

The ability to delete files is not controlled by file permissions, but by the rights to the contained directory.

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

, , www- ( ) sudoers, www-data​​p >

, , umask. umask, : -

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

Source: https://habr.com/ru/post/1770912/


All Articles