解决open()failed (13: Permission denied) while reading upstream的问题

2023-05-16

解决open()failed (13: Permission denied) while reading upstream的问题

前言

    为了提高Nginx的处理能力,我们会配置Nginx配置文件使Nginx启动多个work进程。例如:
    #user root root;
    worker_processes     8;
    worker_cpu_affinity auto;
    #error_log  /dev/null;
    daemon on;
    master_process on;

    启动Nginx后,Nginx的进程信息如下:
    [root@www tengine]# ps -ef |grep nginx
    root      58905      1  0 10:04 ?        00:00:00 nginx: master process ./sbin/nginx
    nobody    58906  58905  0 10:04 ?        00:00:00 nginx: worker process
    nobody    58907  58905  0 10:04 ?        00:00:00 nginx: worker process
    nobody    58908  58905  0 10:04 ?        00:00:00 nginx: worker process
    nobody    58909  58905  0 10:04 ?        00:00:00 nginx: worker process
    nobody    58910  58905  0 10:04 ?        00:00:00 nginx: worker process
    nobody    58911  58905  0 10:04 ?        00:00:00 nginx: worker process
    nobody    58912  58905  0 10:04 ?        00:00:00 nginx: worker process
    nobody    58913  58905  0 10:04 ?        00:00:00 nginx: worker process
    root      58915   3344  0 10:04 pts/0    00:00:00 grep --color=auto nginx


出现问题

    网站页面出现异常,部分信息加载不出来。

浏览器报错


    jquery-2.2.3.min.js:4 GET http://192.168.74.84/v1/pkis/ServerCertRequestList     net::ERR_INCOMPLETE_CHUNKED_ENCODING
    send @ jquery-2.2.3.min.js:4

查看Nginx的error.log

    日志信息如下:
    2017/11/28 16:32:43 [crit] 5100#0: *768 open() "/tengine/fastcgi_temp/4/03/0000000034"     failed (13: Permission denied) while reading upstream, client: 192.168.74.236, server: ,     request: "GET /v1/pkis/ServerCertRequestList HTTP/1.1", upstream:     "fastcgi://127.0.0.1:9000", host: "192.168.74.84"


分析问题及解决方法

分析问题

    出错原因是work进程没有打开/tengine/fastcgi_temp/4/03/0000000034 文件的权限。work进程属于nobody用户组,nobody用户名。因此只要把fastcgi_temp 目录权限赋给nobody用户组,nobody用户名就可以了。

解决问题

 [root@www tengine]# ps aux | grep "nginx: worker process" | awk '{print $1}'
 nobody
 root
 [root@www tengine]# chown -R nobody:nobody fastcgi_temp/


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

解决open()failed (13: Permission denied) while reading upstream的问题 的相关文章

随机推荐