fastCGI 在 stderr 中发送:“主要脚本未知”,同时从上游文件读取响应头存在

fastCGI 在 stderr 中发送:“主要脚本未知”,同时从上游文件读取响应头存在

我查看了其他答案,但仍然没有发现这些配置存在问题:

user  nginx;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    # Metadata cache
    open_file_cache          max=10000 inactive=5m;
    open_file_cache_valid    2m;
    open_file_cache_min_uses 1;
    open_file_cache_errors   on;

    # Buffer
    client_body_buffer_size 10K;
    client_header_buffer_size 1k;
    client_max_body_size 8m;
    large_client_header_buffers 2 32k;

    # Security Headers
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    server {
        listen       80;
        server_name  example.com;
        root /home/web/api;
        index index.php;

    location / {
            try_files $uri /index.php;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:8999
        location ~ [^/]\.php(/|$) {
            include        fastcgi_params;
            fastcgi_pass unix:/var/run/php-fpm/example.com.socket;            
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            #fastcgi_param HTTPS on;
        }

        #if ($http_x_forwarded_proto != "https") {
        #     return 301 https://$server_name$request_uri;
        #}

        location ~ /\.ht {
            deny  all;
        }
    }

}

对于 php-fpm

[example.com]
listen = /var/run/php-fpm/example.com.socket
;listen = 127.0.0.1:9000
listen.backlog = -1
listen.owner = nginx
listen.group = www-data
listen.mode=0660

; Unix user/group of processes
user = nginx
group = www-data
chroot = /

; Choose how the process manager will control the number of child processes.
pm = dynamic
pm.max_children = 75
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500

; Pass environment variables
env[HOSTNAME] = $HOSTNAME

这些文件存在于服务器 vh 的根目录中,由 nginx 拥有,并以 www-data 作为其组。

相关内容