新的Laravel(Homestead)安装:502错误的网关-*刷新*-网站正确显示 [英] New Laravel (Homestead) installation: 502 Bad Gateway - *Refresh* - the website is displayed correctly

查看:227
本文介绍了新的Laravel(Homestead)安装:502错误的网关-*刷新*-网站正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试设置一个本地Laravel项目.因此,我决定使用Homestead流浪者盒子. 在我像

I tried to setup a local Laravel project. So I decided to use the Homestead vagrant box. After I installed the whole thing like in this Tutorial I was looking forward to see the result in the browser:

第一次付款是nginx 502错误网关错误.因此,我尝试对此进行刷新,然后显示默认的Laravel起始页.然后,我做了一些路由和指向我网站的某些子页面的链接,每次更改页面时(通过链接或键入get请求),我都会得到"502错误的网关",它在刷新网站后消失.

The first dispay was a nginx 502 Bad Gateway Error. So I tried to refesh this and after that the default Laravel starting Page was displayed. Then I made some routes and links to some subpages of my site and every time I change my page (via link or typing the get request) i get the "502 Bad Gateway" which disappears after a refresh of the website.

我尝试过:

  • to change the php version (like here)
  • to make the buffer bigger (like here)
  • completely reinstalled my vagrant and VirtualBox
  • use another Browser
  • use an functional Box of my colleague

遗憾的是,有时"502 Bad Gateway"无法显示任何内容.但是在我的同事的PC(也就是Windows 10)上,一切都如您所愿.

Sadly nothing was able to do not display me sometimes the "502 Bad Gateway". But on the Pc of my colleague(Also Windows 10) all things are as you would expect it.

日志文件( /var/log/nginx ):

The log file ( /var/log/nginx ) of the site:

2019/01/23 20:23:53 [error] 2532#2532: *1 recv() failed (104: Connection 
reset by peer) while reading response header from upstream, client: 
192.168.10.1, server: eatthis.test, request: "GET / HTTP/1.1", upstream: 
"fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "eatthis.test"

2019/01/23 20:24:03 [error] 2532#2532: *1 recv() failed (104: Connection 
reset by peer) while reading response header from upstream, client: 
192.168.10.1, server: eatthis.test, request: "GET / HTTP/1.1", upstream: 
"fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "eatthis.test"

和/etc/nginx/sites-enabled/eatthis.test:

And the /etc/nginx/sites-enabled/eatthis.test:

server {
listen 80;
listen 443 ssl http2;
server_name .eatthis.test;
root "/home/vagrant/code/Laravel/public";

index index.html index.htm index.php;

charset utf-8;



location / {
    try_files $uri $uri/ /index.php?$query_string;

}



location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

access_log off;
error_log  /var/log/nginx/eatthis.test-error.log error;

sendfile off;

client_max_body_size 100m;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
}

location ~ /\.ht {
    deny all;
}

ssl_certificate     /etc/nginx/ssl/eatthis.test.crt;
ssl_certificate_key /etc/nginx/ssl/eatthis.test.key;
}

我的Homestead.yaml:

My Homestead.yaml:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: c:/Users/XXXX/.ssh/id_rsa.pub

keys:
- c:/Users/XXXX/.ssh/id_rsa

folders:
- map: c:/www/code
  to: /home/vagrant/code

sites:
- map: eatthis.test
  to: /home/vagrant/code/Laravel/public

databases:
- homestead

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# zray:
#  If you've already freely registered Z-Ray, you can place the token here.
#     - email: foo@bar.com
#       token: foo
#  Don't forget to ensure that you have 'zray: "true"' for your site.

我的主人:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#       127.0.0.1       localhost
#       ::1             localhost
192.168.10.10 eatthis.test

我认为我的PC或流浪汉有问题,但我不知道这可能是什么,因为刷新后文件正在加载.

I think there is a problem on my PC or on my vagrant but i don´t know what this could be, because the files are loading after a refresh.

我希望有人可以帮助我解决这个问题.一直如此令人耳目一新.

I hope somebody can help me out with this problem. This refreshing all the time is so annoying.

推荐答案

亚伦·贝尔兹(Aaron Belz)的确切步骤对我不起作用,但按照链接进行操作即可.

Aaron Belz exact steps didn't work for me, but following the link did.

很不幸,这也是xdebug.

It was xdebug, unfortunately for me too.

sudo vim /etc/php/7.3/mods-available/xdebug.ini

并在所有行前面加上;-然后按照亚伦的指示进行操作:

And prefixed all the lines with ; - then followed Aaron's instructions:

sudo service nginx restart
sudo service php7.3-fpm restart

它奏效了.现在,我担心是否需要xdebug进行任何操作-在找到修复程序之前,我将无法使用它.嗯,当我到达那座桥时越过:D

And it worked. Now I'm worried if I need xdebug for anything - I'm not gonna be able to use it until I find the fix. Ah well, cross that bridge when I get there :D

我还会注意到我在Windows上,而且我知道Vagrant有时会遇到问题,所以也许与此有关.

I will also note I'm on Windows, and I know Vagrant sometimes has problems with that so maybe that has something to do with it.

这篇关于新的Laravel(Homestead)安装:502错误的网关-*刷新*-网站正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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