Debian - Apache - User - Which chown?

7

7

I'm using Debian Wheezy. I've installed apache, php, mysql, the works. It works properly but for permissions that I need to set.

so I have my sites in /var/www/mysite, and I'm struggling between the permissions I should leave for apache and for my normal user. I want apache to be able to create/access files and folders, and I also need my normal user to be able to update, edit, create files and folders.

I've tried these combinations:

chown -R www-data:www-data mysite/ but that doesnt let my user do anything on the files

chown -R www-data:user mysite/ somethings wrong too

chown -R user:www-data mysite/ wrong too

Right now I have this setting:

chown -R user:user mysite/ but then on stuff newly created by apache, my browser cant load these assets and the server returns an error 403

Would be glad for some help

Thanks

Got The Fever Media

Posted 2013-09-27T04:45:15.533

Reputation: 203

Answers

13

I think the best way to do this is to do use your first option:

chown -R www-data:www-data mysite/ 

But then add your user to the www-data group

usermod -a -G www-data user

and then give the group control over the files

chmod 770 -R /var/www/mysite

Chmod 770 basically means both the user who owns the file (in this case www-data) can do read-write-execute and all users in the group assigned to the file (in this case www-data as well) can do read-write-execute.

Mark Winterbottom

Posted 2013-09-27T04:45:15.533

Reputation: 326

Yes, I figured that chmod was the way to go. I'll try also your recommendation of adding a user to the group. Cheers – Got The Fever Media – 2013-09-27T07:57:22.643