- 生成一个新的用户组:www-pub,将用户添加到改组
$groupadd www-pub
$usermod -a -G www-pub usera ## must use -a to append to existing groups
$usermod -a -G www-pub userb
$groups usera ## display groups for user - 修改所有的文件的所有权,分给root:www-pub()
$chown -R root:www-pub /var/www ## -R for recursive - 修改所有的文件夹的权限为2775
$chmod 2775 /var/www ## 2=set group id, 7=rwx for owner (root), 7=rwx for group (www-pub), 5=rx for world (including apache www-data user)
$find /var/www -type d -exec chmod 2775 {} \;
- 修改所有的文件的权限为0664
$find /var/www -type f -exec chmod 0664 {} \; - 修改用户的umask为0002 umask用来控制文件创建的时候默认的权限值,0002是指新创建的文件的权限是664,新创建的文件夹权限是775.这样设置(在文件/etc/profile)意味着一个用户创建的文件可以被属于www-pub用户组里面的任何人修改。
- 参考链接 http://serverfault.com/questions/6895/whats-the-best-way-of-handling-permissions-for-apache2s-user-www-data-in-var
Tuesday, December 13, 2011
Setting up secure apache - 阿帕奇服务器用户和权限配置
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment