Centos 6.5 上的 Nginx + PHP-FPM 给出 502 Bad Gateway(fpm 错误:无法读取子项的内容:错误的文件描述符)

Centos 6.5 上的 Nginx + PHP-FPM 给出 502 Bad Gateway(fpm 错误:无法读取子项的内容:错误的文件描述符)

我正在设置标准 LEMP 堆栈。我当前的设置给出以下错误:

502错误的网关

这是目前我的服务器上安装的内容:

在此处输入图片描述

这是我到目前为止创建/更新的配置,有人可以看看以下内容并找出错误可能出在哪里吗?我已经检查了我的日志,里面什么都没有(https://i.stack.imgur.com/NCpWG.png)我在/var/log/php-fpm/error.log文件。

旁注:nginx 和 php-fpm 都已配置为在名为www-数据服务器上有以下文件夹

在此处输入图片描述

nginx.conf 全局 nginx 配置

user                    www-data;
worker_processes        6;
worker_rlimit_nofile    100000;
error_log               /var/log/nginx/error.log crit;
pid                     /var/run/nginx.pid;

events {
    worker_connections 2048;
    use epoll;
    multi_accept on;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    # cache informations about FDs, frequently accessed files can boost performance
    open_file_cache max=200000 inactive=20s; 
    open_file_cache_valid 30s; 
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    
    # to boost IO on HDD we can disable access logs
    access_log off;

    # copies data between one FD and other from within the kernel
    # faster then read() + write()
    sendfile on;

    # send headers in one peace, its better then sending them one by one 
    tcp_nopush on;

    # don't buffer data sent, good for small data bursts in real time
    tcp_nodelay on;

    # server will close connection after this time
    keepalive_timeout 60;

    # number of requests client can make over keep-alive -- for testing
    keepalive_requests 100000;

    # allow the server to close connection on non responding client, this will free up memory
    reset_timedout_connection on;

    # request timed out -- default 60
    client_body_timeout 60;

    # if client stop responding, free up memory -- default 60
    send_timeout 60;

    # reduce the data that needs to be sent over network
    gzip on;
    gzip_min_length 10240;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
    gzip_disable "MSIE [1-6]\.";

    # Load vHosts
    include /etc/nginx/conf.d/*.conf;
}

conf.d/www.domain.com.conf 我的虚拟主机条目

## Nginx php-fpm Upstream
upstream wwwdomaincom {
    server unix:/var/run/php-fcgi-www-data.sock;
}

## Global Config
client_max_body_size            10M;
server_names_hash_bucket_size   64;

## Web Server Config
server
{
    ## Server Info
    listen 80;
    server_name domain.com *.domain.com;
    root /home/www-data/public_html;
    index index.html index.php;
    
    ## Error log
    error_log /home/www-data/logs/nginx-errors.log;

    ## DocumentRoot setup
    location / {
        try_files $uri $uri/ @handler;
        expires 30d;
    }
    
    ## These locations would be hidden by .htaccess normally
    #location /app/                       { deny all; }
    
    ## Disable .htaccess and other hidden files
    location  /. {
        return 404;
    }
 
    ## Magento uses a common front handler
    location @handler {
        rewrite / /index.php;
    }
 
    ## Forward paths like /js/index.php/x.js to relevant handler
    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }
 
    ## Execute PHP scripts
    location ~ \.php$ {
        try_files $uri =404;
        expires        off;
        fastcgi_read_timeout 900;
        fastcgi_pass   wwwdomaincom;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    
    ## GZip Compression
    gzip on;
    gzip_comp_level 8;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain application/xml text/css text/js application/x-javascript;
}

/etc/php-fpm.d/www-data.conf 我的 php-fpm 池配置

## Nginx php-fpm Upstream
upstream wwwdomaincom {
    server unix:/var/run/php-fcgi-www-data.sock;
}

## Global Config
client_max_body_size            10M;
server_names_hash_bucket_size   64;

## Web Server Config
server
{
    ## Server Info
    listen 80;
    server_name domain.com *.domain.com;
    root /home/www-data/public_html;
    index index.html index.php;
    
    ## Error log
    error_log /home/www-data/logs/nginx-errors.log;

    ## DocumentRoot setup
    location / {
        try_files $uri $uri/ @handler;
        expires 30d;
    }
    
    ## These locations would be hidden by .htaccess normally
    #location /app/                       { deny all; }
    
    ## Disable .htaccess and other hidden files
    location  /. {
        return 404;
    }
 
    ## Magento uses a common front handler
    location @handler {
        rewrite / /index.php;
    }
 
    ## Forward paths like /js/index.php/x.js to relevant handler
    location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }
 
    ## Execute PHP scripts
    location ~ \.php$ {
        try_files $uri =404;
        expires        off;
        fastcgi_read_timeout 900;
        fastcgi_pass   wwwdomaincom;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    
    ## GZip Compression
    gzip on;
    gzip_comp_level 8;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain application/xml text/css text/js application/x-javascript;
}

我有一个文件/主页/www-数据/public_html/index.php使用代码<?php phpinfo(); ?>(作为用户上传的文件www-data)。

答案1

nginx tmp 目录不可由用户写入 nginx 正在以“www-data”的身份运行

/var/lib/nginx/tmp/fastcgi/2/00/0000000002”失败(13:权限被拒绝)

尝试“chown -cR www-data. /var/lib/nginx”

相关内容