Orc*_*ans 8 php nginx vagrant laravel bad-gateway
我试图建立一个当地的Laravel项目.所以我决定使用Homestead vagrant box.在我安装了本教程中的所有内容后,我期待在浏览器中看到结果:
第一次出现的是nginx 502 Bad Gateway Error.所以我试着改写它,然后显示默认的Laravel起始页面.然后我做了一些路线和链接到我的网站的一些子页面,每次我更改我的页面(通过链接或键入获取请求)我得到"502坏网关",刷新网站后消失.
我试过了:
可悲的是,没有什么能够不显示我有时"502 Bad Gateway".但是在我的同事(也是Windows 10)的PC上,所有的东西都是你所期望的.
站点的日志文件(/ var/log/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"
Run Code Online (Sandbox Code Playgroud)
和/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;
}
Run Code Online (Sandbox Code Playgroud)
我的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.
Run Code Online (Sandbox Code Playgroud)
我的主持人:
# 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
Run Code Online (Sandbox Code Playgroud)
我认为我的PC或我的流浪汉有问题,但我不知道这可能是什么,因为文件在刷新后加载.
我希望有人可以帮我解决这个问题.这种清爽一直很烦人.
小智 13
Aaron Belz确切的步骤对我没有用,但跟着链接做了.
不幸的是,这也是xdebug.
sudo vim /etc/php/7.3/mods-available/xdebug.ini
Run Code Online (Sandbox Code Playgroud)
;然后按照Aaron的指示,将所有线条加上前缀:
sudo service nginx restart
sudo service php7.3-fpm restart
Run Code Online (Sandbox Code Playgroud)
它奏效了.现在我很担心我是否需要xdebug - 在找到修复程序之前我不能使用它.啊,当我到达那里时,穿过那座桥:D
我还会注意到我在Windows上,我知道Vagrant有时会遇到问题,所以可能与它有关.
小智 7
同样的问题(nginx 上出现 502 错误)。我知道这是一个老问题,但最近又发生了,因为尚未包含此更改
release 的分支 中存在问题: https://github.com/laravel/homestead/pull/1691/commits/78a573f62a9160e8d9c302667649089cf8a2435claravel\homestead
所以就我而言,运行 php 7.4 这两行解决了问题:
sudo systemctl enable php7.4-fpm
sudo service php7.4-fpm restart
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1336 次 |
| 最近记录: |