【问题标题】:Nginx serving file error 403 forbiddenNginx服务文件错误403禁止
【发布时间】:2017-12-05 08:55:47
【问题描述】:

先介绍一下这个问题的历史;我在 digitalocean 上设置了一个 django 站点,首先使用 root 复制,django 文件夹作为所有者 root 并且我一直致力于修复这个问题,现在该站点启动并运行,但一个图像仍然有 403 禁止错误。

我正在寻找可以更改此文件权限的命令。

-rwxr----- 1 sammy sammy 566719 Jul  1 14:52 developer.jpg

【问题讨论】:

    标签: nginx


    【解决方案1】:
    chmod -R 777 folder_name
    
    chmod -R 777 file.name //when You are in directory where this file exist
    

    chmod -R 777 file_path/file.name
    

    【讨论】:

    • 将权限更改为 777 不是一个好习惯 - 请参阅 'The problem with 777' on this answer
    • 是的,不是,但他可以检查是否有帮助,然后更改它们。同样对于只有图像的文件夹来说也不错。
    【解决方案2】:

    您的 NGINX 用户可能正在使用 www-data 或其他用户,以验证 NGINX 在 shell 执行中使用的用户:

    grep user /etc/nginx/nginx.conf
    

    然后更改文件权限:

    chown www-data:www-data developer.jpg
    

    查看您的文件权限,他们还需要调整 - see this answer for recommended perms

    (可能需要sudo,将www-data 替换为您的NGINX 用户)

    【讨论】:

      猜你喜欢
      • 2015-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-19
      • 2016-03-26
      • 1970-01-01
      • 1970-01-01
      • 2018-02-20
      相关资源
      最近更新 更多