如何调试“在stderr中发送的FastCGI:从上游读取响应头时未知主脚本”并找到实际的错误消息? [英] How to debug "FastCGI sent in stderr: Primary script unknown while reading response header from upstream" and find the actual error message?

查看:361
本文介绍了如何调试“在stderr中发送的FastCGI:从上游读取响应头时未知主脚本”并找到实际的错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SO有很多文章提到了此错误代码:

SO has many articles mentioning this error code:

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream...

这可能意味着此错误消息或多或少没有用。

That probably means that this error message is more or less useless.

该消息告诉我们,由于某些原因,FastCGI处理程序不喜欢发送的任何内容。问题是有时我们不知道原因是什么。

The message is telling us that the FastCGI handler doesn't like whatever it was sent for some reason. The problem is that sometimes we have no idea what the reason is.

所以我要重新陈述一个问题-我们如何 调试 这个错误代码?

So I'm re-stating the question -- How do we debug this error code?

考虑一下我们有一个非常简单的站点(仅包含phpinfo.php文件)的情况。此外,还有一个非常简单的nginx配置,如下所示:

Consider the situation where we have a very simple site, with just the phpinfo.php file. Additionally, there is a very simple nginx config, as follows:

server {
    server_name testsite.local;

    root /var/local/mysite/;

    location / {
        index index.html index.htm index.php;
    }

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  fastcgi_backend;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

我们如何才能准确看到输出/日志

我们如何看到实际的错误消息?就我而言,我是使用php-fpm。它在日志中没有有关此错误的信息。日志不会为此错误添加任何行。 php-fpm是否有详细模式?

How can we see the actual error message? In my case, I'm using php-fpm. It has no info in the log about this error. The logs do not append any rows for this error. Is there a verbose mode for php-fpm?

/var/log/php-fpm/error.log
/var/log/php-fpm/www-error.log

我尝试设置此值在php-fpm.conf文件中

I've tried to set this in the php-fpm.conf file

log_level = notice

,并且在php-fpm.d / www.conf文件中:

and this in the php-fpm.d/www.conf file:

catch_workers_output = yes


推荐答案

要回答您的问题:



To answer your question:


  1. 在php-fpm.d / www.conf文件中:

设置access.log条目:

set the access.log entry:

access.log = /var/log/$pool.access.log




  1. 重新启动php- fpm服务。

  1. restart php-fpm service.

尝试访问您的页面

cat / var / log / www.access.log,您将看到以下访问日志:

cat /var/log/www.access.log, you will see access logs like:

--10 / Nov / 2016:19:02:11 +0000 GET /app.php 404
--2016年11月10日:19:02:37 +0000 GET /app.php 404


  • 如果看到 GET /而没有正确的php文件名,则是您的nginx conf问题。

  • if you see "GET /" without a correct php file name, then it's your nginx conf problem.

如果看到 GET /app.php和404,表示nginx正确传递了脚本文件名,但php-fpm无法访问该文件(用户 php-fpm:php-fpm无权访问您的文件,困了我三个小时)

if you see "GET /app.php" with 404, it means nginx is correctly passing the script file name but php-fpm failed to access this file (user "php-fpm:php-fpm" don't have access to your file, which trapped me for 3 hours)

希望我的回答有所帮助。

Hope my answer helps.

这篇关于如何调试“在stderr中发送的FastCGI:从上游读取响应头时未知主脚本”并找到实际的错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆