我想保留root作为/ var / www
的所有者我希望小组/var/www
可以/var/www/*
和www-data
访问(rwx)。
我相信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?!
答案 0 :(得分:0)
回答:注销,然后重新登录以使组更改生效。 (那是Barmar的答案。)