nginx - nginx 显示 502 错误网关
问题描述
502 网关错误。错误日志和nginx配置如下。这有什么问题吗?
[错误] 7660#0:*10 connect() 失败(111:连接被拒绝)同时连接到上游,客户端:40.83.126.181,服务器:127.0.0.1,请求:“GET / HTTP/1.1”,上游:“fastcgi ://127.0.0.1:9000”,主机:“www.mysite.com”
nginx.conf:
worker_processes 1;
events {
worker_connections 1024;
}
http{
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name 127.0.0.1;
location / {
root /www;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
include vhost/*.conf;
}
虚拟主机/home.conf:
server {
listen 80;
server_name www.mysite.com
#charset utf-8;
access_log /www/host.access.log;
error_log /www/error.log;
root /www;
index index.php index.html index.htm;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 100d;
}
location ~ .*\.(js|css)?$ {
expires 30d;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php(/|$) {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
解决方案
运行php-fpm,确保nginx和php-fpm在同一个用户(组)下,问题解决。
推荐阅读
- javascript - 为什么我不能在我的 React 应用程序中使用“npm start”?
- spring - how to stop default query on id when using @cacheable annotation
- reactjs - React redux props undefined
- javascript - Javascript prevent decrement past 0
- python - 您如何处理在 Python 中生成许多变量或对象的任务?
- c++ - 什么是“#include
“? - python-3.x - 在特定小时之间每 10 秒运行一次 bash 脚本
- c# - Handle Linq queries outputs
- python - 在python中使用for循环时如何更新列表
- javascript - 动态创建的字段/ID 中的 foreach 解决方案