我想保持 root 作为 /var/www 的所有者
我想通过 group 制作/var/www
和/var/www/*
访问(rwx)www-data
。
我相信 apache 的用户是www-data
. 我将自己(用户:)添加devon
到该组,但我仍然无法将文件保存到/var/www/html
. 帮助!
这很清楚我试图做的事情(以下)。我错过了什么?!
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?!