6

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

R.Teloyan
  • 65
  • 1
  • 1
  • 5
  • Do you have the permissions needed to create the file? Please provide more information as to what you are trying to do and how – Dylan May 01 '16 at 19:50
  • 3
    Possible duplicate of [Whats the simplest way to edit and add files to "/var/www"?](http://askubuntu.com/questions/19898/whats-the-simplest-way-to-edit-and-add-files-to-var-www) – guntbert May 05 '16 at 18:16

2 Answers2

10
sudo chown -R $USER:$USER /var/www/html
Rinzwind
  • 293,910
  • 41
  • 570
  • 710
Magneto10
  • 302
  • 3
  • 8
  • 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
  • 734
  • 3
  • 8
  • 27
  • 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