欢迎光临
我们一直在努力

NGINX报错:Primary script unknown解决办法

NGINX错误日志内容如下:

2018/09/30 20:01:02 [error] 19321#19321: *2877 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 117.163.227.90, server: 4spaces.org, request: "GET /plus/90sec.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.4spaces.org", referrer: "http://bijie.jinti.com/plugins/weathermap/configs/test404.php"

解决办法如下:

修改nginx配置文件,

location ~ \.php$ {
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
           include        fastcgi_params;
        }

将上面的内容修改为:

location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
        include        fastcgi_params;
    }

$document_root 代表当前请求在root指令中指定的值:

server {
   listen 443 ssl http2;
   server_name 4spaces.org www.4spaces.org;
   index  index.php index.html index.htm;
   root   /etc/nginx/html/rxblog;
   add_header X-Frame-Options DENY;
   add_header X-Content-Type-Options nosniff;

   ssl_certificate /etc/letsencrypt/live/4spaces.org/fullchain.pem;
   ssl_certificate_key /etc/letsencrypt/live/4spaces.org/privkey.pem;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
   ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
   ssl_prefer_server_ciphers on;
   ssl_session_cache shared:SSL:10m;
   ssl_session_timeout 60m;

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

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
        include        fastcgi_params;
    }

}

上面的配置表示:针对/etc/nginx/html/rxblog/目录下的php文件进行解析。

参考文章:

  1. 记一次Nginx-Primary script unknown的报错解决
赞(1)
未经允许不得转载:Ddmit » NGINX报错:Primary script unknown解决办法

评论 抢沙发

登录

找回密码

注册