4

I am a web developer and have Apache setup on my local system for testing.

I keep running into issues with the permissions e.g. unless I chmod any new directories to 777 my IDE cannot write to the files there.

I was hoping there was a way to add myself to the group that has control of the www folder (and any sub folders) so I do not have to chmod the files every time.

Hailwood
  • 5,017

4 Answers4

5

I am working on a related issue, but in your case, you could just add yourself to the web group

sudo adduser $USER www-data

replace USER$ with your username of course. www-data is the group used for apache web access.

saji89
  • 12,187
Alan
  • 66
4

don't use 777 just because it "works". You can use easier notation such as u+rwx in order to give the user the right permission. g for group, u for "user" and o for "others". chmod ugo+rwx is then equal to 777; anyone can do anything with any files or directory. Usually not what you want.

You may want to use setgid on the directory using chmod g+s. This way, when someone changes a file, the group ownership will stay the same. Also, when you create new files and directories, this will be inherited.

1

If you use an desktop environment, you can do this.
Open the terminal and enter:

gksudo nautilus

Enter your password and hit Enter. Navigate to the www folder and right-click. Choose properties and afterwards permission. Now you can change the access.
To quit Nautilus, just close it and to close the terminal, idem.

BuZZ-dEE
  • 14,533
Ward
  • 277
  • 1
  • 2
  • 14
0

You could do this, if you just want to add your user:

sudo chgrp -R yourusername /var/www
sudo find /var/www -type d -exec chmod g=rwxs {} \;
sudo find /var/www -type f -exec chmod g=rws {} \; 

Replace yourusername with the actual user name that you want to add. One last thing, you can keep adding user names by repeating the command, only putting their user name.

Hope this helps!

Source

Max Tither
  • 1,354