Score:0

Permissions for www root folder for non root user

ar flag

I need to allow a non-root user to access (read and write) the webserver's web root folder /var/www/html. I need some help on how to best accomplish this. I want to avoid setting permissions too broadly.

Currently, permissions are as follows:

root@prodwww:/# ls -al /var/www/
total 12
drwxr-xr-x  3 root root     4096 Aug  6 08:52 .
drwxr-xr-x 15 root root     4096 Aug  6 08:52 ..
drwxr-x---  8 root www-data 4096 Aug 18 21:45 html
root@prodwww:/#

and within /var/www/html

root@prodwww:/# ls -al /var/www/html/
total 88
drwxr-x---  8 root www-data  4096 Aug 18 21:45  .
drwxr-xr-x  3 root root      4096 Aug  6 08:52  ..
...
-rw-r-----  1 root www-data   628 Jul  7  2016  _htaccesss
-rw-r--r--  1 root root     10918 Aug 18 21:45  index.html
...
root@prodwww:/#

The user is in the group users but if I changed the folder's group to 'users', then www-data (Apache web server) group could not access.

Should I

  • add www-data to group users and change /var/www/html 's group to users?
  • add the user's account to the www-data group?
  • create a new group and add the user's account and the apache user account to that group and change the folders group to the new group?
  • perhaps set Apache (www-data) as the owner and set the group to users?
  • do something else?
Score:0
fr flag

If your files/folder has frequently updated, it's better to create a new user E.g:

sudo useradd myuser

then change Apache user:

sudo nano /etc/apache2/envvars

to:

export APACHE_RUN_USER=myuser
export APACHE_RUN_GROUP=myuser

Then change recursively the chmod to 755 or 744:

sudo chown myuser:myuser /var/www/html
sudo chmod -R 755 /var/www/html

another option you can use www-data as group and add myuser to the group.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.