What is the recommended user, group and directory permissions for the webroot directory?
Let say I have the below directory structure,
/var/www/
/website-1/htm/
index.html
/website-2/html/
index.html
Currently, I have
drwxr-xr-x 7 root root 4096 Jun 23 14:52 www
drwxr-xr-x 3 root root 4096 Jun 13 04:47 website-1
drwxr-xr-x 3 root root 4096 Jun 23 14:52 website-2
drwxrwxr-x 3 myuser myuser 4096 Aug 8 07:10 html
As you can see, the html folder is owned by my current user and group. I know this is not correct. I’ve read that it should be www-data but again others I’ve read also are using root and even user accounts.
What would be the “best” recommended user:group and permission?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello, I don’t know if I understood your question well but I had problems with the permissions on my site and the answer to this question helped me a lot, I also wait for you
Hi @Kdimitrov
Once again, thanks for the help.
With 755, the group has no Write permissions. This is a problem for my setup because I have another user that uploads/edits the site.
Do you think it’s okay if I will change the /var/www/website/html directory permission to 775 to allow groups from uploading?
And all files and directories inside html will be 644 and 755 respectively.
Also, what’s your take on setting the permissions and user:group of newly created or uploaded files automatically? Ways I’ve read so far are umask and setgid.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.