2

As a webmaster I need fast access to /var/www, what should I set in dir permissions to get rid of 'open as admin' in order to file modification and creation? Yet I want it safe as modificable from my machine only.

Or is there a way to always open everything as admin?

Esamo
  • 1,542

4 Answers4

2

here's my suggestion:

$ sudo chown www-data:www-data -R /var/www

(changes the permissions to be owned by www-data). I'm not sure why it defaults to root anyways.

$ sudo gpasswd -a $USER www-data   (add yourself to the www-data group)
$ sudo chmod g+rw -R /var/www  #make all files write by group owner.
$ sudo find -type d -exec chmod g+rwx {} \;  #find folders and make sure group has rwx access.

logout, log back in.

you should now be able to write any files as yourself.

You could simply chown /var/www to your $USER, though I wouldn't recommend it. partly because it's insecure, and partly because I think some things will probably break if you do.

csgeek
  • 1,659
1

I'm assuming your talking about Apache. If that's the case, I would set the user and group to the user apache is running under (this can be found out with ps aux|grep apache|awk '{print $1}'). This will make the files and directory only editable by root. Here's the command to change permissions (if apache is the user):

 chown -R www-data:www-data /var/www
krab
  • 13
  • 3
1

Or is there a way to always open everything as admin?

May be you want:

cd /var/www/
sudo -u www-data
krab
  • 13
  • 3
1

i used this command

Sudo chown -Rv www-data /var/www

Dont need to logout / end your desktop season. i log always as root when i want to work in localhost, after i add some files i always use that command.