I have setup a LAMP, and I am confused about which permissions to use. From what I've read it is often mentioned that files on the web server should be owned by www-data:www-data, as that is the account Apache runs on.
So now my current setting for all web server files are:
-rwxrwxr-x www-data : www-data
The account I log in to FTP is called admin, and is a member of the www-data group. (I’ve read that due to security, it is not possible to log in as www-data)
The problem I have is that I often need to delete files, and copy old files (restoring backup) to the web server through FTP. This means that the files I am uploading to the server will be owned by “admin”, and get default permission as “-rw-r- -r- -“. It isn’t very practical to need to run chown / chmod command every time I load something up. And will it matter if the files are being owned by admin, instead of www-data? As long as www-data is the owner group, wouldn’t that be sufficient for Apache?
What is best practice when it comes to this kind of scenario? Is it possible to automatically make the system apply the wanted ownership/permission to every file that is uploaded to the webserver? Or should I use some other permission settings?