I've just setup a new Droplet over at DigitalOcean before the weekend and have been configuring to my needs. I've been following this previously asked question multiple owner of same folder.
I also found another Q/A on this same forum this weekend talking about security implications and how to properly secure the www folder to minimise any potential risks.
What I've done so far is created a new group webmasters, where I've added myself, any other people that need access and the www-data user.
Applied the
setgid
bit on the foldersudo chmod g+s /var/www/html
so that newly created files and folder belong to the same group to avoid access issues.
Once all that is done, how exactly do I properly secure the /var/www/html folder?
I read somewhere that in a perfect world, the folder would have chmod
set to 640 or 2750, and that the www-data
user should only have read access, where you manually give it write access to upload folders and so on.
Am I missing something important here?
I'm trying my best to learn.
www-data
is owner of the document directory, highly depends on which application/CMS will be placed inside. For example WordPres and nextCloud would likewww-data
to be owner of their DocumentRoot directories, because they will write inside, will do updates, etc. On other hand MediaWiki will need to have write access only to certain directories, e.g. uploads, etc. – pa4080 Aug 07 '19 at 10:09www-data
needs only read permissions to the files, and read-execute permissions to the directories. So the default permissions 755 to the directories (where where last 5 meansr-x
for the other users) and 644 to the files (where the lat 4 meansr
for the other users) should be enough (when all folders are owned byroot:webmasters
)... if you need help to set these permissions, I could write ana answer. – pa4080 Aug 07 '19 at 10:48data
where the webserver/client will upload/edit data in, beyond that it shouldn't be a problem. Just manually set that folder (and subfolders) to 775 I assume? – Dixos Aug 07 '19 at 10:54