jjzjj

php - 新的 Laravel (Homestead) 安装 : 502 Bad Gateway - *Refresh* - the website is displayed correctly

coder 2024-01-02 原文

我试图建立一个本地 Laravel 项目。所以我决定使用 Homestead vagrant box。 在我像this Tutorial一样安装了整个东西之后我期待在浏览器中看到结果:

第一个显示是 nginx 502 Bad Gateway Error。所以我尝试刷新它,然后显示默认的 Laravel 起始页面。然后我制作了一些路由和链接到我网站的一些子页面,每次我更改我的页面(通过链接或输入 get 请求)我都会得到“502 Bad Gateway”,它会在网站刷新后消失。

我试过:

  • 更改 php 版本 ( like here )
  • 使缓冲区更大(like here)
  • 完全重新安装了我的 vagrant 和 VirtualBox
  • 使用其他浏览器
  • 使用我同事的功能性 Box

遗憾的是,有时无法显示“502 Bad Gateway”。但是在我同事的电脑上(还有 Windows 10)一切都如你所料。

日志文件( /var/日志/nginx ) 的网站:

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:

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:

---
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 或我的 vagrant 有问题,但我不知道这可能是什么,因为文件在刷新后正在加载。

我希望有人能帮我解决这个问题。这种一直刷新实在是太烦人了。

最佳答案

Aaron Belz 的确切步骤对我不起作用,但点击链接却起作用。

这是 xdebug,对我来说也是不幸的。

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

并在所有行前加上 ; - 然后按照 Aaron 的说明进行操作:

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

它奏效了。现在我担心是否需要 xdebug 来解决任何问题——在找到修复程序之前我将无法使用它。啊好吧,当我到达那里时穿过那座桥 :D

我还会注意到我在 Windows 上,我知道 Vagrant 有时会遇到问题,所以这可能与它有关。

关于php - 新的 Laravel (Homestead) 安装 : 502 Bad Gateway - *Refresh* - the website is displayed correctly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54335705/

有关php - 新的 Laravel (Homestead) 安装 : 502 Bad Gateway - *Refresh* - the website is displayed correctly的更多相关文章

  1. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  2. ruby - 使用 Vim Rails,您可以创建一个新的迁移文件并一次性打开它吗? - 2

    使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta

  3. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  4. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  5. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  6. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  7. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  8. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  9. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

  10. ruby - 安装 Ruby 时遇到问题(无法下载资源 "readline--patch") - 2

    当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub

随机推荐