将服务器从 16.04 更新到 18.04.4 LTS 后,我收到 502 Bad Gateway (nginx/1.14.0 (Ubuntu))

将服务器从 16.04 更新到 18.04.4 LTS 后,我收到 502 Bad Gateway (nginx/1.14.0 (Ubuntu))

首先,我运行了nginx -t,没有出现任何错误。然后我尝试检查error.log文件

我运行了这个命令 tail -30 /var/log/nginx/error.log,读到错误信息后,我发现路径错误unix:/run/php/php7.0-fpm.sock。我不使用 php7.0,我使用 php7.2,我应该怎么做才能更正这个路径?

我已经尝试通过命令完全删除 php7.0,apt-get purge php7.0但仍然收到 502 Bad Gateway。我收到的错误来自tail -30 /var/log/nginx/error.log

2020/03/05 12:21:15 [crit] 1073#1073: *65 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 192.241.218.89, server: 45.76.203.111, request: "GET /ReportServer HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "45.76.203.111"
2020/03/05 12:23:12 [crit] 1073#1073: *70 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 35.231.52.19, server: unigates.com, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:24:36 [crit] 1073#1073: *75 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 35.231.52.19, server: unigates.com, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.unigates.com"
2020/03/05 12:34:30 [crit] 1073#1073: *83 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 51.36.64.136, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:34:48 [crit] 1073#1073: *86 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 207.46.13.53, server: unigates.com, request: "GET /profile/jeddah-international-college HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:36:37 [crit] 1073#1073: *89 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 123.125.71.85, server: unigates.com, request: "GET /profile/emirates-academy-of-hospitality-management HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.unigates.com"
2020/03/05 12:41:38 [crit] 1073#1073: *92 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:43:56 [crit] 1073#1073: *95 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 37.9.113.92, server: unigates.com, request: "GET /program/search?category=6 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:44:17 [warn] 1013#1013: server name "https://unigates.com$request_uri" has suspicious symbols in /etc/nginx/sites-enabled/unigates.com:59
2020/03/05 12:44:17 [warn] 1036#1036: server name "https://unigates.com$request_uri" has suspicious symbols in /etc/nginx/sites-enabled/unigates.com:59
2020/03/05 12:44:22 [crit] 1044#1044: *1 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:44:42 [crit] 1044#1044: *4 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 141.8.132.36, server: unigates.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:44:49 [crit] 1044#1044: *1 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:45:42 [crit] 1044#1044: *1 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:45:44 [crit] 1044#1044: *1 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:52:12 [crit] 1044#1044: *10 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:54:13 [crit] 1044#1044: *10 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 12:54:15 [crit] 1044#1044: *10 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 13:00:32 [warn] 5348#5348: server name "https://unigates.com$request_uri" has suspicious symbols in /etc/nginx/sites-enabled/unigates.com:59
2020/03/05 13:11:08 [crit] 1044#1044: *17 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 46.229.168.144, server: unigates.com, request: "GET /program/14 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 13:11:16 [crit] 1044#1044: *19 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 13:23:03 [crit] 1044#1044: *26 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 95.163.255.179, server: 45.76.203.111, request: "GET /program/1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "ww38.unigates.com"
2020/03/05 13:53:55 [crit] 1044#1044: *31 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 54.36.148.225, server: unigates.com, request: "GET /program/search?page=4 HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "demo.unigates.com"
2020/03/05 14:00:13 [crit] 1044#1044: *34 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 46.229.168.131, server: unigates.com, request: "GET /register HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 14:13:33 [crit] 1044#1044: *38 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 14:14:05 [crit] 1044#1044: *38 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 14:15:45 [crit] 1043#1043: *1 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 197.37.0.193, server: unigates.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 14:32:47 [crit] 1043#1043: *6 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 46.229.168.146, server: unigates.com, request: "GET /program/27 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.unigates.com"
2020/03/05 14:36:09 [crit] 1043#1043: *8 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 157.55.39.60, server: unigates.com, request: "GET /program/11 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"
2020/03/05 14:48:16 [crit] 1043#1043: *10 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 42.242.10.165, server: unigates.com, request: "GET /program/search?category=3 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "unigates.com"

..当我检查 nginx 服务状态时,systemctl status nginx我得到了“活动,正在运行”和这 3 行。

Mar 05 15:32:55 unigates systemd[1]: Stopped A high performance web server and a reverse proxy server.
Mar 05 15:32:55 unigates systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 05 15:32:55 unigates systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Mar 05 15:32:55 unigates systemd[1]: Started A high performance web server and a reverse proxy server.

请协助。

答案1

我通过配置这个文件解决了这个问题sudo nano /etc/nginx/sites-available/default 然后改变这一行形式

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

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

相关内容