代客502错误网关nginx / 1.19.1

时间:2020-07-22 21:13:11

标签: php macos nginx homebrew laravel-valet

我有macOS High Sierra 10.13.6,并且我在Laravel Valet 2.11.0上本地运行WordPress网站。 昨天,我在本地设置中遇到了其他一些问题,并通过brew更新/升级和其他一些调整设法解决了该问题。从那以后,一切运行良好,直到我过夜重新启动笔记本电脑。现在,前端出现错误“ 502 Bad Gateway nginx / 1.19.1 ”。

我认为这与PHP无法正确链接有关,但无法确定到底是什么错误。

nginx-error.log文件中的错误:

2020/07/22 22:27:41 [crit] 75400#0: *1 connect() to unix:/Users/klara1/.config/valet/valet.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: domainname.test, request: "GET /favicon.ico HTTP/2.0", upstream: "fastcgi://unix:/Users/klara1/.config/valet/valet.sock:", host: "domainname.test", referrer: "https://domainname.test/“
brew list | grep php
php
php@7.1
php@7.2
php@7.3

which php
/usr/local/opt/php@7.3/bin/php

php -v                                                                                                                                                                   7s
PHP 7.3.20 (cli) (built: Jul 10 2020 00:02:14) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies

ps ax | grep php
72830 s000  R+     0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn php

php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.3
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.3/conf.d/php-memory-limits.ini

当我运行sudo brew services restart nginx && sudo brew services restart php73时,我最终得到一个错误:

==> Successfully started `nginx` (label: homebrew.mxcl.nginx)
Error: No available formula with the name "php73"
brew link php73
Error: No such keg: /usr/local/Cellar/php73

brew info php73
Error: No available formula with the name "php73"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.

运行valet stop时,它将停止两个不同的PHP版本:

valet stop
Stopping php...
Stopping php@7.2...
Stopping php@7.3...
Stopping nginx...
Valet services have been stopped.

我已经完成了以下推荐的故障排除方法(https://laracasts.com/discuss/channels/general-discussion/updating-to-php-73):

brew unlink php && brew link php 
brew services restart —all 
composer global update 
valet start

也:

brew update
brew upgrade php

也:

valet install

但是没有任何效果……仍然会出现相同的错误。请问有人知道这可能是什么吗?任何帮助表示赞赏!

2 个答案:

答案 0 :(得分:3)

我相信您必须增加标头的缓冲区大小,

open Users/YOUR-USER/.config/valet/Nginx/WEBSITE.test

在每fastcgi_pass行之后添加以下行

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

然后

valet restart

祝你好运!希望对您有帮助

答案 1 :(得分:0)

我将此添加到/usr/local/etc/nginx/nginx.conf中的http,并解决了Magento 2的问题,这可能也对wordpress有所帮助

fastcgi_buffering on;
fastcgi_buffers 4 256k;
fastcgi_buffer_size 128k;