php7.2-fpm 超时 nginx wsl 18.04

php7.2-fpm timeout nginx wsl 18.04

我最近从 Ubuntu wsl 16.04 升级到 18.04。

完成后我恢复本地开发,很高兴找到(差不多) 一切正常。

出于某种原因,我现在使用 php-fpm

时遇到此错误

2018/09/19 21:17:26 [error] 3736#3736: *1 upstream timed out (110: Connection timed out) while reading upstream, client: ::1, server: _, request: "GET /register HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"

这里是我的/etc/nginx/sites-available/default文件的相关内容。

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;

            # With php7.0-cgi alone:
            fastcgi_pass 127.0.0.1:9000;
            # With php7.0-fpm:
            #fastcgi_pass unix:/run/php/php7.2-fpm.sock;
            fastcgi_read_timeout 300;
    }

以及/etc/php/7.2/fpm/pool.d/www.conf

中的相关行

listen = 127.0.0.1:9000

我也试过取消注释 listen.allowed_clients = 127.0.0.1 但还是一样。

这里一定有我遗漏的东西。 www.conf 文件在升级期间被重置为默认值,它必须在其中。非常感谢任何帮助。

解决方案是将它放在我的 nginx 配置的位置块中:

fastcgi_buffering off;

第一行

为来自 github

的 Nginx 尝试下面的配置
location ~ \.php$ {
    proxy_set_header X-Forwarded-Proto $scheme;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_buffering off; # This must be here for WSL as of 11/28/2018
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PHP_VALUE "upload_max_filesize = 20M \n post_max_size=21M";
    include /etc/nginx/fastcgi.conf;

}