Hi All,
Just finished setting up my Ubuntu 16.04 LTS droplet and so far, so good.
I have read across various sites and forums on the various ways to grant/add permissions/users with regards to accessing the www folder and subsequent folders within www.
My question: is there an official stand DigitalOcean has on this that ensures top security for an application being served by apache?
Or, which users/permissions are mandatory/standard for a classic, secure apache server?
I am planning to write a script to ensure such users/permissions are always set.
Comments, links etc. are highly welcome.
Thanks.
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!
Hi guys, reading this i have this issue, tks. https://www.digitalocean.com/community/questions/apache2-folders-permissions-ubuntu-20-04
Hi, such a cool thread about this topic here are commands that works for me note that I’ve based the commands on the discussion and examples above:
sudo usermod -a -G www-data $USER
sudo chown root:root /var/www
sudo chmod -R 755 /var/www
sudo chown -R www-data:www-data /var/www/*
/var/www
There is no anything special about it. Default permissions are safe, so you should be good to go.
Defaults are, owner:group is root:root and mod is 755. 755 means that everybody can read and execute files, but only owner is able to write.
<^>Subdirectories, /var/www/html
Now, this depends on your needs. Default owner:group is root:root. This is OK and secure if you’re serving static content from your site.
Problem arises if you want to write something to files within your website (change existing files or upload new files) . Root privileges would not allow you to do so. To fix it you need to set ownership to www-data:www-data or sammy:www-data.
You need to pay attention to make sure that you set www-data permissions only to directories (files) that you need to change from website.
Setting it to /var/www/html or even /var/www is not recommended as it is big security hole.
If you want to know more, www-data is Web server group, that means that Web server, so Web server users can change/write data.
If you’re using static content, root:root with mod 755 are probably best settings.
For dynamic, set www-data ownership only to files/directories where you need it.
There are many links on the Internet, like: default permissions on AskUbuntu adding files on AskUbuntu and so on…
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.