6

how to enable to create New document or new folder in var/www/html ? "my Ubuntu is 16.04"

2 Answers2

10
sudo chown -R $USER:$USER /var/www/html
Rinzwind
  • 299,756
Magneto10
  • 302
  • 2
    the only issue I see with this answer would be that /var/www should be owned by www-data:www-data. Wouldn't it have been more compatible to add the user to the www-data group? – John Orion May 01 '16 at 20:12
  • 2
    You should avoid changing the system-wide files and directories to specific users. You should either use the elevated (sudo) command to editing the create the needed files or add the username to the group of the owner. You can also (as the second answer specifies), create a subfolder and make it owned by the user or group you intend to read/write access to it. – L. D. James May 02 '16 at 04:32
  • @L.D.James;@JohnOrion.. I'm newer in ubuntu and i didn't know what to do but @magneto10's answer helped me:) – R.Teloyan May 02 '16 at 17:40
  • 2
    This post is actually a workaround and the disclaimers of what this would cause (as pointed out by @L.D.James) should be clearly stated in the post. – Andrea Lazzarotto May 05 '16 at 16:05
  • After try this sudo chown -R $USER:$USER usr in centos 7 , user login issue, before the command user login working. @Magneto10 – Gem Oct 01 '19 at 04:48
3

To do it from the terminal:

sudo mkdir /var/www/html/YOUR_DIRECTORY_NAME

You don't want to give yourself ownership of /var/www/html

kalenpw
  • 744
  • 1
    "You don't want to give yourself ownership of /var/www/html" good point but the "why?" should also be explained. – SarpSTA Mar 23 '19 at 13:20