Unable to save files to /var/www/html --even though I'm in group www-data

1.1k Views Asked by At

I want to keep root as owner of /var/www

I want to make /var/www and /var/www/* accessible (rwx) by the group www-data.

I believe apache's user is www-data. I added myself (user: devon) to that group, but I still cannot save a file to /var/www/html. Help!

Here is very clearly what I tried to do (following). What did I miss?!

devon@cheap-dell /var $ ls -l
...
drwxrwsr-x  3 root www-data 4096 Apr 22 01:06 www
devon@cheap-dell /var $ cd www
devon@cheap-dell /var/www $ ls -l
total 2
drwxrwxr-x 4 root www-data 4096 Apr 22 17:25 html
devon@cheap-dell /var/www $ id devon
uid=1000(devon) gid=1000(devon) groups=1000(devon),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),110(sambashare)
devon@cheap-dell /var/www $ groups devon
devon : devon adm cdrom sudo dip plugdev lpadmin sambashare
devon@cheap-dell /var/www $ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
devon@cheap-dell /var/www $ groups www-data
www-data : www-data
devon@cheap-dell /var/www $ sudo usermod -a -G www-data devon
devon@cheap-dell /var/www $ # just to be sure......
devon@cheap-dell /var/www $ sudo chgrp -R www-data /var/www
devon@cheap-dell /var/www $ sudo chgrp -R www-data /var/www/*
devon@cheap-dell /var/www $ sudo chmod -R g+rw /var/www
devon@cheap-dell /var/www $ sudo useradd -g www-data devon
useradd: user 'devon' already exists
devon@cheap-dell /var/www $ # good!
devon@cheap-dell /var/www $ ls -l
total 2
drwxrwxr-x 4 root www-data 4096 Apr 22 17:25 html
devon@cheap-dell /var/www $ cd html
devon@cheap-dell /var/www/html $ touch example
touch: cannot touch ‘example’: Permission denied
devon@cheap-dell /var/www/html $ # wtf?! I'm logged in as user devon
devon@cheap-dell /var/www/html $ echo ${APACHE_RUN_USER}

devon@cheap-dell /var/www/html $ # ?? where is it?
devon@cheap-dell /var/www/html $ users ${APACHE_RUN_USER}
devon devon devon devon
devon@cheap-dell /var/www/html $ # I would have expected user www-data, right?  
devon@cheap-dell /var/www/html $ groups ${APACHE_RUN_USER}
devon adm cdrom sudo dip plugdev lpadmin sambashare
devon@cheap-dell /var/www/html $ groups devon
devon : devon adm cdrom sudo dip www-data plugdev lpadmin sambashare
devon@cheap-dell /var/www/html $ sudo usermod -a -G www-data www-data
devon@cheap-dell /var/www/html $ touch example
touch: cannot touch ‘example’: Permission denied
devon@cheap-dell /var/www/html $ # why?!
1

There are 1 best solutions below

0
On

THE ANSWER: log out, then log back in for the group changes to take effect. (That's Barmar's answer.)