Egrodo Egrodo - 4 months ago 12
Apache Configuration Question

Is there any reason that the apache webroot /var/www/html is set as root-owned?

I just launched a LAMP dropplet from Digital Ocean and am starting coding. When trying to create a new directory inside the web root it says

mkdir: cannot create directory ‘blog’: Permission denied

I can fix this by running
chown -R user /var/www/html
but I'm wondering if this will break things or if there's a better way of doing this. Thanks!


You have a variety of options on permissions, but essentially www-data needs read (and probably execute) permission.

I like to redefine the DocumentRoot in my VirtualHost definitions to use something other than /var/www/html, anyway.

For example, you could use /srv/www/sitename, and then assign permissions myuser:www-data to it.

There are also numerous threads on the DigitalOcean forums (and around the internet) about permissions schemes for web files. (e.g. Proper Permissions for Web Server Directory.)