首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >502服务器恢复后的Bad网关Nginx

502服务器恢复后的Bad网关Nginx
EN

Stack Overflow用户
提问于 2017-08-11 17:30:28
回答 3查看 2.3K关注 0票数 11

所以我有一个Ubuntu服务器,我正试图从备份中恢复它。当一个虚拟PHP版本页面,我得到502坏网关。我想修什么?很多事情,包括这个相关问题的答案- nginx 502 bad gateway

这是我使用Ubuntu的默认配置。

代码语言:javascript
运行
复制
server {
listen 80;
#   listen [::]:81 ipv6only=on default_server;

root /var/www/html;
index index.php index.html index.htm;

server_name localhost;

location ~* \.(js|css|png|jpg|jpeg|gif|ico|html)$ {
        expires max;
}


location / {
    try_files $uri $uri.php $uri.php/$args /index.php?q=$uri&$args $uri/ =404;
    index index.php index.html index.htm;
    rewrite ^(.*)$ /$1.php;
}

location /phpmyadmin {
  index index.php;
    try_files $uri $uri/ =404;
    auth_basic "Admin Login";
    auth_basic_user_file /etc/nginx/pma_pass;
}

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_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
}


location ~ /\.ht {
    deny all;
}
}

编辑:下面是我认为日志的相关部分

代码语言:javascript
运行
复制
2017/08/11 13:18:13 [error] 27759#0: *270 connect() failed (111: Connection refused) while connecting to upstream, client: 66.61.18.112, server: domain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "[IP ADDRESS]", referrer: "http://[IP ADDRESS]/phpmyadmin/index.php"

编辑2:

下面是我运行ps aux | grep php-fpm时的结果

代码语言:javascript
运行
复制
mre      21685  0.0  0.0  11756   932 pts/0    S+   10:42   0:00 grep --color=auto php-fpm
root     32721  0.0  1.0 269300 11168 ?        Ss   Aug11   0:30 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)                    
www-data 32724  0.0  0.4 269300  4540 ?        S    Aug11   0:00 php-fpm: pool www                                                       
www-data 32725  0.0  0.4 269300  4540 ?        S    Aug11   0:00 php-fpm: pool www 

编辑3:

以下是我的php-fpm.conf中未注释的内容

代码语言:javascript
运行
复制
[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = /var/run/php5-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = /var/log/php5-fpm.log


;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ; 
;;;;;;;;;;;;;;;;;;;;

; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5/fpm/pool.d/*.conf

编辑4:

以下是我的www.conf中未发表评论的内容:

代码语言:javascript
运行
复制
listen = 127.0.0.1:9000
listen.owner = www-data  
listen.group = www-data
listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /

编辑5:

在我尝试访问index.php之后,我的nginx日志:

代码语言:javascript
运行
复制
[error] 29393#0: *23 connect() failed (111: Connection refused) while connecting to upstream, client: [Computer IP Address], server: [Subdomain.domain.com], request: "GET /favicon.ico HTTP/1.1", upstream:"http://127.0.0.1:8080/favicon.ico", host: [Server IP], referrer: "http://[Server IP]/index.php"
EN

Stack Overflow用户

回答已采纳

发布于 2017-08-16 18:45:05

因此,我检查了我的nginx配置并找到了以下行:

代码语言:javascript
运行
复制
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

然后我去了/etc/nginx/conf.d/*.conf,在servers.conf文件中看到了一个子域的配置,我计划使用它,但不会再使用了,所以我删除了它。这是问题的很大一部分,因为nginx首先关注这个配置,这就是为什么错误包括这个子域。

至于php问题,我将配置切换到fastcgi_pass unix:/run/php/php7.0-fpm.sock;,这似乎解决了问题。

票数 5
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45640770

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档