1

Possible Duplicate:
Whats the simplest way to edit and add files to “/var/www”?

I'm fairly new to Ubuntu, and Linux in particular. I want to use Ubuntu for web development mostly, so I went ahead and installed LAMP manually using this guide. Everything works good. Apache, PHP, MySQL are all working perfectly fine, but there's this permission issue.

My files are going to be in /var/www, but I don't have permissions to this directory. How would I make it so that I have the permissions to edit, view (also in browser), delete, and create files in this directory?

Note that I am not hosting a server, so security is not an issue. I will be managing my project locally.

4
  • If security isn't an issue, 777 all the files! sudo chmod 777 /var/www/* This will give read/write/execute permissions to all the files in www/*
    – Dr_Bunsen
    Dec 29, 2012 at 16:07
  • But I suppose I'd have to do it for every new file I copy to this directory? I have no clear idea, so pardon my lack of knowledge.
    – Rafay
    Dec 29, 2012 at 16:09
  • I thought it unlocked the folder. If you remove the * at the end of the command, it will unlock the folder, to unlock anything in it, add that *.
    – Dr_Bunsen
    Dec 29, 2012 at 16:12
  • Voting to close as this is a dupe, but I got an interesting answer here in a similar question. Dec 29, 2012 at 20:00

1 Answer 1

1

Instead of making your files world open, you can use ACL to give one of your groups the permissions to the whole subtree. ACL are more flexible than regular permissions in my opinion and a default rule can be used to apply to new files/directories.

sudo apt-get install acl

To use, you have the command setfacl and getfacl

man acl will explain the concept and man setfacl will give you all the use ptions but here is a suggestion:

sudo setfacl -Rm d:g:<your-user-main-group>:rwX,g:<your-user-main-group>:rwX /var/www

Will give your main group rw permissions and x on the directories (to enter them).

-R: recursive
-m: modify existing rule (the actual permissions)

d:g:<...>:rwX = default part for new files, group permissions
g:<...>:rwX   = applied to the existing files/directories
rwX           = read, write and change directory allowed (rwx will allow file execute too)

If you prefer, instead of using your main group (if you have other users for example), you can create a group (webdev for example) and use it:

sudo addgroup webdev
sudo adduser your-user webdev

and use webdev group in the acl instead of your-user-main-group

Obs: you can also use ACLs with users (u:) or others (other:) instead of groups.

Not the answer you're looking for? Browse other questions tagged .