started learning server deployment. Until the end did not understand about chmod , chown ... please explain:

on the server, Apache \ PHP work from the www-data user, I created an ftp account, and gave it to a friend .. he went in and created a file there, say, 2.txt and PHP does not want to work with it in any way, because the owner of this file is this ftuser , which is logical (the one who created it)

 -rw-r--r-- 1 www-data www-data 8 окт 18 07:06 1.txt -rw-r--r-- 1 ftpuser ftpuser 0 окт 18 07:14 2.txt 

but the file above which is (1.txt) is created via php

I understand that you can give the rights manually, but I wanted everything to be automated ... so that php and ftp-user could work with files

works on vsftpd

although ftp account added to the group ...

 root@serv:~# groups ftpuser ftpuser : www-data 
  • you have read -rw-r--r-- only rights for the group: -rw-r--r-- , so it does not matter that there is a user in the group. - Evgenii Izhboldin

1 answer 1

Work with group rights. Create a common group, or use one of the existing ones, for example: groupadd www-pub

and add www-data and ftpuser

 usermod -a -G www-pub www-data usermod -a -G www-pub ftpuser 

Change the group for this directory: chgrp -R www-pub dir and issue permissions for the necessary ones, for example chmod -R 774 dir

After that, both Apache and FTP should have shared access to the directory.