OK, so i recently installed Ubuntu for web development and i noticed 2 things:
I need to use
$ sudo
for editing files (in www-data: … file / s), for example$ sudo atom / var / www / index.html
. If i do not use this command, atom will say i not have the permission.I also need to use
$ sudo
for somes commands, for example for$ git commit -m
new commiti will need to use
$ sudo
. But it’s probably because git don’t have the right permissions.
I tryed $ sudo chown -R www-data: anatole
(anatole is my username on ubuntu) but wordpress need www-data: www -data permission for adding plugins …
I think i’m root cause i can use sudo commands and i’m the only user on this computer.
So if somone have the solution i’m realy intrested to know it.
Advertisement
Answer
You can give yourself write rights in the /var/www directory:
- add yourself to the www-data group using
addgroup $USER www-data
. You will have to log out and back in for this to take effect. Check withgroups
- give all group memebers write access using
chmod g+w /var/www -R
in the directory tree.
- add yourself to the www-data group using
It sounds as if you have your git repository right in /var/www. This is bad security practice, because you could very well end up exposing your git repository on the web. I know that this may not be an issue on the development machine, but this may change without your being aware of it. I would move the .git repository out of the directory. You could use some kind of access control like .htaccess or deny www-data access to the .git directory but this can break, easily. I would probably use symlinks to the files and directories.