Homestead 中的 502 Bad Gateway nginx (1.9.7) [Laravel 5]

502 Bad Gateway nginx (1.9.7) in Homestead [ Laravel 5 ]

google 和其他各种搜索引擎,但仍然无法解决。 这是我的场景:

Larave 5 on homestead

1) ps -eo pid,comm,euser,supgrp | grep nginx [以下是输出]

2333 nginx root root 2335 nginx vagrant adm,cdrom,sudo,dip,www-data,plugdev,lpadmin,sambashare,vagrant

2) 根据一些搜索结果,做了以下内容:/etc/php/7.0/fpm/pool.d

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

3) 使用 sudo 服务输出 php7.0-fpm restart

  • Restarting PHP 7.0 FastCGI Process Manager php-fpm7.0 [ OK ]

4) 输出 sudo service nginx restart

nginx stop/waiting
nginx start/running, process 2650

5)输出:

sudo /etc/init.d/nginx restart
  • Restarting nginx nginx [fail]

6)output with: tail -f /var/log/nginx/error.log

> 2015/12/26 15:35:23 [notice] 2088#2088: signal process started
2015/12/26 15:45:23 [notice] 2266#2266: signal process started
2015/12/26 15:45:23 [alert] 2095#2095: *9 open socket #3 left in connection 5
2015/12/26 15:45:23 [alert] 2095#2095: aborting
2015/12/26 15:49:02 [alert] 2303#2303: *1 open socket #3 left in connection 3
2015/12/26 15:49:02 [alert] 2303#2303: aborting
2015/12/26 16:00:39 [notice] 2475#2475: signal process started
2015/12/26 16:02:25 [notice] 2525#2525: signal process started
2015/12/26 16:03:08 [notice] 2565#2565: signal process started
2015/12/26 16:14:45 [notice] 2645#2645: signal process started

` 我只是在这个 502 Bad Gateway

上玩得很开心
> nginx/1.9.7

和php

> PHP 7.0.1-1+deb.sury.org~trusty+2 (cli) ( NTS )

` 如果有人可以帮助我继续处理这种情况,那就太好了。并且,提前谢谢你。

终于解决了这个here。我要感谢 laracast 讨论中的 Miguel。

您需要更改以下配置文件:

/etc/nginx/sites-enabled

change line fastcgi_pass for

 fastcgi_pass unix:/run/php/php7.0-fpm.sock;

php7.0-fpm.sock 位于:

/var/run/php

由于新 VM 使用 php 7.* 并且您的配置文件可能具有 5.6 版本的 php 位置。

然后重启Nginx和PHP

sudo service nginx restart

sudo service php7.*-fpm restart

7.3 和 Homestead 8..* 中的 xdebug 版本不兼容。找到更多信息 *

我遇到了同样的问题...并以简单的方式解决了它:

如果你使用作曲家,只需替换旧的:

laravel/homestead (v2.*)

与:

laravel/homestead (v3.0.1)

/etc/php/7.0/fpm/pool.d/www.conf

试试这个
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

终于重启php7.0-fpm

service php7.0-fpm restart

如果您在配置 Homestead box 后更改站点 属性,您应该重新运行 vagrant reload --provision 以更新虚拟机上的 Nginx 配置。

这是我的故事 我安装了最新的 homestead 并尝试 运行 我的 Laravel 5.4 项目但是经过一天的调试所以为我的项目提供了自定义 php 。这就是它的工作原理。

 1. vi Homestead.yaml
 2. sites:
    - map: homestead.test
      to: /home/vagrant/code/my-project/public
      php: "7.1"

php 7.1 works from Laravel 5.4 to 5.7

 3. vagrant up --provision 

我遇到了同样的错误,502 Bad Gateway (Ngix 1.blablabla)

很容易解决它。

只需在您的终端中输入即可。

如果您的虚拟机是 运行:

vagrant reload --provision

其他:

vagrant halt

及以后:

vagrant up --provision