AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 899397
Accepted
Dave
Dave
Asked: 2018-03-01 13:51:11 +0800 CST2018-03-01 13:51:11 +0800 CST 2018-03-01 13:51:11 +0800 CST

如何设置我的 nginx 权限以允许多部分表单提交?

  • 772

我在 CentOS 7 上使用 Nginx 和 Puma(用于 Rails 应用程序)。我对如何设置文件上传权限感到困惑。目前,当我尝试上传文件(提交多部分表单)时,我在 nginx 错误日志中收到以下错误

2018/02/28 16:35:48 [crit] 31241#0: *148 open() "/var/lib/nginx/tmp/client_body/0000000006" failed (13: Permission denied), client: 96.92.233.165, server: example.com, request: "POST /people HTTP/1.1", host: "example.com", referrer: "http://example.com/people/new"

我试图让所有东西都以“rails”用户身份运行。以下是我的 nginx 和 puma 进程

[root@server /]# ps -elf | grep nginx
0 S root       944   920  0  80   0 -  2249 pipe_w 16:38 pts/1    00:00:00 grep --color=auto nginx
1 S root     31238     1  0  80   0 - 30712 rt_sig 15:06 ?        00:00:00 nginx: master process /usr/sbin/nginx
5 S rails    31239 31238  0  80   0 - 30843 ep_pol 15:06 ?        00:00:00 nginx: worker process
5 S rails    31240 31238  0  80   0 - 30843 ep_pol 15:06 ?        00:00:00 nginx: worker process
5 S rails    31241 31238  0  80   0 - 30843 ep_pol 15:06 ?        00:00:00 nginx: worker process
5 S rails    31242 31238  0  80   0 - 30843 ep_pol 15:06 ?        00:00:00 nginx: worker process
[root@server /]# ps -elf | grep puma
1 S rails      582     1  0  80   0 - 135430 poll_s 16:19 ?       00:00:00 puma 3.11.2 (tcp://0.0.0.0:3000,unix:///home/rails/scale_production/shared/sockets/puma.sock) [scale_production]
1 S rails      590   582  0  80   0 - 286725 futex_ 16:19 ?       00:00:02 puma: cluster worker 0: 582 [scale_production]
1 S rails      594   582  0  80   0 - 287282 futex_ 16:19 ?       00:00:03 puma: cluster worker 1: 582 [scale_production]
1 S rails      596   582  0  80   0 - 287255 futex_ 16:19 ?       00:00:02 puma: cluster worker 2: 582 [scale_production]
1 S rails      599   582  0  80   0 - 286939 futex_ 16:19 ?       00:00:02 puma: cluster worker 3: 582 [scale_production]
0 S root       946   920  0  80   0 -  2250 pipe_w 16:38 pts/1    00:00:00 grep --color=auto puma

以下是有问题的目录的权限。为了使它起作用,我还应该设置什么?

[root@server /]# ls -al /var/lib/nginx
total 12
drwx------  3  755 rails 4096 Feb 24 14:33 .
drwxr-xr-x 23 root root  4096 Feb 24 14:33 ..
drwx------  7  755 rails 4096 Feb 24 15:06 tmp
[root@server /]# ls -al /var/lib/nginx/tmp/client_body
total 8
drwx------ 2 rails rails 4096 Feb 24 15:06 .
drwx------ 7   755 rails 4096 Feb 24 15:06 ..
[root@server /]# ls -al /var/lib/nginx/tmp
total 28
drwx------ 7   755 rails 4096 Feb 24 15:06 .
drwx------ 3   755 rails 4096 Feb 24 14:33 ..
drwx------ 2 rails rails 4096 Feb 24 15:06 client_body
drwx------ 2 rails rails 4096 Feb 24 15:06 fastcgi
drwx------ 2 rails rails 4096 Feb 24 15:06 proxy
drwx------ 2 rails rails 4096 Feb 24 15:06 scgi
drwx------ 2 rails rails 4096 Feb 24 15:06 uwsgi
nginx
  • 2 2 个回答
  • 2217 Views

2 个回答

  • Voted
  1. Best Answer
    Michael Hampton
    2018-03-01T14:50:16+08:002018-03-01T14:50:16+08:00

    您正在以名为的用户身份运行 nginx rails(这很不寻常)。

    但是您的一个目录 ,/var/lib/nginx/tmp由不存在的用户 755 拥有。

    发生这种情况的通常原因是chown您的意思是错误地输入了chmod.

    您应该能够通过更正此目录的所有权来解决问题。

    chown rails /var/lib/nginx/tmp
    

    顺便说一句,您似乎也禁用了 SELinux。你应该尽早解决这个问题。

    • 2
  2. Sunny Chawla
    2018-04-19T23:45:43+08:002018-04-19T23:45:43+08:00

    您可以看到/var/lib/nginx/tmp由用户 755 拥有。可能您使用了错误的命令:chown而不是chmod.

    要解决这个问题:

    chmod 755 /var/lib/nginx/tmp
    chown rails /var/lib/nginx/tmp
    
    • 2

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve