I created a php file and it creates a few files in the directory when viewed with the browser. These files are owned by www-data and now I can't delete them via the command line. But when I run this PHP file on the command line, the files are owned by the user correctly and I can delete them. How can I make sure when these files are created when viewed in the browser, I can delete them with that user?
Asked
Active
Viewed 25 times
0
-
`chmod` or `chown` maybe `chgrp`. – AbraCadaver Jun 16 '21 at 22:36
-
no i need the ownership be the user when viewed via the browser. not www-data – Patoshi パトシ Jun 16 '21 at 22:39
-
do you have control on the web server configuration? – Wadih M. Jun 16 '21 at 22:43
-
PHP can do those commands look them up php.net – AbraCadaver Jun 16 '21 at 22:45
-
No permissions on the file are needed to delete them. Fix the permissions on the directory and you will be able to delete files. You'll need permissions that allow both you and www-data to write to it. Adding both users to a common group and using 775 permissions would be an easy solution. – miken32 Jun 16 '21 at 23:20
-
@Patoshiパトシ the only way to do so is if you reconfigure your webserver to run as the user instead of www-data. There are ways to do so, and some security considerations that goes with it. But just from a theoretical standpoint, so you see why this is happening. – Wadih M. Jun 17 '21 at 00:06
-
You can add your user to the www-data group, then make sure your script creates the files with group write permissions. – Rob Ruchte Jun 17 '21 at 01:56
-
can i just set it to nobody when these files are created? so my user can manipulate these files? – Patoshi パトシ Jun 17 '21 at 13:21
-
@Patoshiパトシ You won't be able to bypass this reality. Linux file system permissions is at the heart of everything. Better spend the time to learn about it, might take you a couple days, but well worth it. Good luck! – Wadih M. Jun 17 '21 at 18:13