nginx php7.1 lararel,家园中的502 Bad Gateway nginx(1.9.7)[Laravel 5]

谷歌和各种其他搜索引擎,但仍然无法解决它.

这是我的场景:

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服务nginx重启输出

nginx stop/waiting

nginx start/running, process 2650

5)输出:

sudo /etc/init.d/nginx restart

Restarting nginx nginx [fail]

6)输出: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.我要感谢Miguel从laracast讨论.

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

/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位置.

标签:homestead,laravel-5,nginx,vagrant

来源: https://codeday.me/bug/20190823/1694703.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
出现502 Bad Gateway错误通常是由于Nginx无法连接到后端Laravel应用程序造成的。这可能是由于Laravel应用程序没有正确运行,或者Nginx配置文件不正确导致的。以下是一些可能的解决方法: 1. 检查Laravel应用程序是否正确运行。您可以尝试在命令行运行php artisan serve命令来启动Laravel开发服务器,然后在浏览器访问应用程序,如果能正常访问,则说明Laravel应用程序已正确运行。 2. 检查Nginx配置文件是否正确。请确保您的Nginx配置文件的root路径正确指向Laravel应用程序的public目录。例如: ``` server { listen 80; server_name example.com; root /path/to/laravel/public; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ``` 请注意,上述配置文件的root路径应该指向您的Laravel应用程序的public目录。 3. 检查php-fpm是否正在运行。如果您使用的是php-fpm,那么请确保php-fpm正在运行。您可以使用以下命令检查php-fpm的状态: ``` systemctl status php-fpm ``` 如果php-fpm未运行,请使用以下命令将其启动: ``` systemctl start php-fpm ``` 4. 检查Nginxphp-fpm用户组是否匹配。请确保Nginxphp-fpm都在同一个用户组。例如: ``` user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } } ``` 请注意,上述配置文件的user指令应该指向您的php-fpm用户组。 如果您尝试了以上所有解决方法仍然无法解决问题,请尝试查看Nginxphp-fpm的错误日志,以获取更多的信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值