php - Laravel 502 Bad Gateway Nginx 流量高时
问题描述
我正在使用 Laravel 应用程序,下面是我的 nginx 配置代码:
server {
listen 80;
server_name domain.com;
root /var/www/project/public;
index index.html index.htm index.php index.nginx-debian.html;
charset utf-8;
location ~ /.well-known {
allow all;
}
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/domain.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
错误日志
2018/06/29 08:41:30 [error] 928#928: *14875 connect() to unix:/run/php/php7.0-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: IP, server: IP, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "IP"
我的配置有问题吗?我有一台配备 32GB 内存、SSD 和处理器的重型服务器:2x E5-2670 0 @ 2.60GHz。我正在使用带有 NGINX 的 Ubuntu。
请告诉我,我已经更改了许多服务器,但无法摆脱这个问题。
解决方案
检查您的 php-fpm 日志以查看 nginx 是否正在死亡。您得到的错误是 Nginx 说它正在代理请求的服务器没有响应。如果它们在两台不同的机器上,这可能是网络问题,可能是因为没有足够的工作人员来满足所有传入的请求,也可能是 VPS 上的 OOM 杀手杀死了进程。仅仅因为服务器拥有大量 RAM 并不意味着它不会受到内存耗尽的影响。我有一个 Magento 网站的客户,由于插件编码不佳,他的一天结束报告在具有类似规格的服务器上引发了内存错误。
我刚刚看到您从日志中发布了一行。检查您的 pool.conf 是否有以下内容:
process.max、pm.max_children、pm.min/max_spare_servers
这些只是您在交通繁忙的环境中可能需要调整的部分内容。
推荐阅读
- python - 从文件创建环境而无需其他依赖项
- reactjs - 我在哪里可以找到 FontAwesome 免费包中图标的对象名称?
- php - 索引页面不显示 db 的对象或有时显示未定义的变量
- html - 如何以以下方式在表格的单元格内叠加图像?
- excel - 使用 microsoft graph api 将 Excel 文件 (.xlsx) 转换为 PDF 忽略页面设置说明
- javascript - url 字符串中包含“v0”的 Firebase 存储下载 URL
- azure-webjobs - 如何为“webjobs v3”中的不同队列配置不同的批处理大小?
- php - 无法在 Windowsn 10 Pro build 1809 上安装 Composer:SSL 操作失败,代码为 1
- python - ImportError:没有名为“selenium”的模块(Selenium 存在)
- sql - 我正在使用游标从临时表中获取行,但如果条件不起作用,这是在 MSSQL 上执行此类任务的好方法吗?