/var/www/html 的权限 [英] Permissions for /var/www/html

查看:38
本文介绍了/var/www/html 的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 GoDaddy 的虚拟 CentOS 服务器,但我在设置 /var/www/html 的权限时遇到问题.

I have a virtual CentOS server with GoDaddy, and I'm having trouble setting up the permissions for /var/www/html.

不允许用户以 root 身份登录,甚至不能将自己添加到 root 组,所以这是我自己画的角落:

Users are not allowed to log in as root, or even add themselves to the root group, so here's the corner I've painted myself into:

  • 我使用以下命令更改了它的所有者(我使用了 httpd.conf 中的 user:group):

  • I changed its owner using the following command (I used the user:group that was in httpd.conf):

chown -R apache:apache /var/www/html

  • 我将自己的用户添加到了 apache 组:

    usermod -a -G apache myuser
    

  • 我更改了权限:

  • I changed the permissions:

    chmod 777 /var/www/html -R
    

  • 这是让我的 SFTP 帐户能够在 /var/www/html 中创建、更改、删除文件的唯一方法.第777章!(SFTP 帐户使用与 ssh 帐户相同的凭据,这意味着就所有意图和目的而言,它们都是相同的,对吗?)

    This is the only way to give my SFTP account the ability to create, change, and delete files in /var/www/html. 777! (The SFTP account uses the same credentials as the ssh account, which means for all intents and purposes they're the same, right?)

    我显然是 Linux 服务器管理员的新手,但这似乎非常不安全.有没有更好的方法来做到这一切?

    I'm obviously new to Linux server admin, but this seems ridiculously insecure. Is there a better way to do all this?

    注意我打算在这里建立的网站将允许文件上传、cron 作业等,所以我猜这也会使必要的权限复杂化.对吗?

    Note The website I'm planning on putting up here will allow file uploads, cron jobs, etc., so I'm guessing that will complicate the necessary permissions as well. Is that correct?

    更新 使用 775 似乎不起作用;我可以上传/覆盖文件,但是当我尝试删除它们时,FileZilla 给了我这个错误:

    Update Using 775 does not appear to work; I can upload/overwrite files, but when I just try to delete them, FileZilla gives me this error:

    rm/var/www/html/index.php:权限被拒绝

    rm /var/www/html/index.php: permission denied

    我不知道为什么,但改回 777 可以修复"这个问题.

    I have no idea why, but changing back to 777 "fixes" this.

    推荐答案

    你只需要 775 for /var/www/html 只要你以我的用户.中间的 7 八进制(用于组"acl)确保该组具有读/写/执行权限.只要您属于拥有这些文件的组,myuser"就应该能够写入它们.不过,您可能需要为文档根目录中的所有文件授予组权限:

    You just need 775 for /var/www/html as long as you are logging in as myuser. The 7 octal in the middle (which is for "group" acl) ensures that the group has permission to read/write/execute. As long as you belong to the group that owns the files, "myuser" should be able to write to them. You may need to give group permissions to all the files in the docuemnt root, though:

    chmod -R g+w /var/www/html
    

    这篇关于/var/www/html 的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆