www 数据权限?
所以我在 /var/www 中有一个目录(称为 cake),我需要允许 www-data 写入它,但我也想写入它(无需使用 sudo)。我担心将权限更改为 777,以防我的计算机上的其他用户(或黑客)尝试修改该目录中的文件。如何只允许我自己和 Apache 的 www-data 访问?
So I have a directory in /var/www (called cake) and I need to allow www-data to write to it, but I also want to write to it (without having to use sudo). I'm afraid to change the permissions to 777 in case some other user on my machine (or a hacker) attempts to modify files in that directory. How do I only allow access for myself and Apache's www-data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
然后
第一个命令更改所有者和组。
第二个命令添加
s
属性,该属性将使 cake 中的新文件和目录具有相同的组权限。then
First command changes owner and group.
Second command adds
s
attribute which will keep new files and directories within cake having the same group permissions.正如 Slicehost 的一篇文章所述:
As stated in an article by Slicehost:
假设您想通过 sftp 进入与 www-data 共享读取、写入和执行权限的目录,您应该执行以下操作:
1 - 将自己添加到 www-data 组
2 - 设置所需的用户:文件夹的组所有权,并files recursively
3 - 这为所有用户添加了权限(读写执行)(a+rwx);限制他人的权限(o-rwx);为该目录 (ug+s) 下创建的每个新文件设置相同的(继承文件夹)用户:组。这将递归执行,并且仅在文件夹中执行(可能正是您想要的)
Let's say you want to sftp into a directory sharing reading, writing and executing permissions with www-data, this is what you should do:
1 - Add yourself to www-data group
2 - Sets the wanted user:group ownership for your folder and files recursively
3 - This adds permissions (read write execute) to all users (a+rwx); Restrict permissions from others (o-rwx); Sets the same (folder inherited) user:group for every new file created under that directory (ug+s). This will be executed recursively and only in folder (probably exactly what you want)
检查根目录的用户
本例中的用户名是 sapama
在 gedit /etc/apache2/envvars 中编辑该目录的用户和组
重新启动 Apache sudo 服务 apache2 重新启动
Check the user of the root directory
The username in this case is
sapama
Edit the user and group of that directory in the
gedit /etc/apache2/envvars
Restart Apache
sudo service apache2 restart