PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 2, 2022

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

 February 02, 2022     apache, digital-ocean, lamp, web-services, webserver     No comments   

Issue

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!


Solution

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.)



Answered By - Jameson
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing