紧急:Ubuntu 服务器升级后 Nginx 崩溃

紧急:Ubuntu 服务器升级后 Nginx 崩溃

之前尝试过将 Nginx 从 1.14 升级到 1.14.1。但在 apt-get upgrade 中我得到了:

mysite systemd[1]: Starting A high performance web server and a        reverse proxy server...
mysite nginx[31861]: nginx: [emerg] duplicate upstream  "fastcgi_backend" in /etc/nginx/sites-enabled/mysite.conf.save:1
mysite nginx[31861]: nginx: configuration file  /etc/nginx/nginx.conf test failed
mysite systemd[1]: nginx.service: Control process exited,  code=exited status=1
mysite systemd[1]: Failed to start A high performance web server     and a reverse proxy server.
mysite systemd[1]: nginx.service: Unit entered failed state.
mysite systemd[1]: nginx.service: Failed with result 'exit-code'.
dpkg: error processing package nginx-full (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
nginx depends on nginx-full (<< 1.14.1-0+xenial0.1~) | nginx-light (<<   1.14.1-0+xenial0.1~) | nginx-extras (<< 1.14.1-0+xenial0.1~); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.
nginx depends on nginx-full (>= 1.14.1-0+xenial0) | nginx-light (>=  1.14.1-0+xenial0) | nginx-extras (>= 1.14.1-0+xenial0); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.

我在 mysites.conf 文件中有这些内容:

upstream fastcgi_backend {
server   127.0.0.1:9000;
#server unix:/run/php/php7.2-fpm.sock;
}

server {
listen 80;
server_name mysite.com;
return 301 https://www.example.com$request_uri;
}

server {
listen 80 default_server;
server_name www.example.com; # dev.www.example.com;
root   /home/public_html;

#check http_x_forwarded_proto value that comes from load balancer
set $my_http "http";
set $my_ssl "off";
set $my_port "80";

if ($http_x_forwarded_proto = "https") {
  set $my_http "https";
  set $my_ssl "on";
  set $my_port "443";
}

#cut off port from url
port_in_redirect off;

#setup log files
access_log  /home/www_logs/access.log;
error_log /home/www_logs/error.log;

include includes/blocks.conf;

# Include Security rules for Mageto
include includes/security.conf;

# Tell browsers that website should olways be accessible via HTTPS
# add_header Strict-Transport-Security "max-age=15984000" always;

# Include redirects
include includes/redirects.conf;

# Include static
include includes/static.conf;



# Add rewrite for product feeds
location ~ ^/en/skroutzfeed\.xml {
    expires 24h;
    try_files /home/public_html/skroutzfeed_en.xml /skroutzfeed_en.xml =404;
}
location ~ ^/el/skroutzfeed\.xml {
    expires 24h;
    try_files /home/public_html/skroutzfeed_gr.xml /skroutzfeed_gr.xml =404;
}
location ~ ^/skroutzfeed\.xml {
    expires 24h;
    try_files /home/public_html/skroutzfeed_gr.xml /skroutzfeed_gr.xml =404;
}
#include includes/phpmyadmin.conf;
#include includes/solr.conf;

#location ~ ^/el {
#    #set $magento_run_code "el";
#    #set $magento_run_type "store";
#}

#location ~ ^/en {
#    #set $magento_run_code "en";
#    #set $magento_run_type "store";
#}

location / {
    #expires 30d;
    index index.html index.php;
    set $magento_run_code "el";
    set $magento_run_type "store";
    try_files $uri $uri/ @handler;
}

location @handler {
    rewrite / /index.php;
}

#location = /js/index.php/x.js {
#    rewrite ^(.*\.php)/ $1 last;
#}

location ~ \.php {
    expires  off;
  # fastcgi_pass   fastcgi_backend;
    fastcgi_buffers 8 32k;
    fastcgi_buffer_size 64k;
    fastcgi_busy_buffers_size 64k;
    fastcgi_connect_timeout 3000s;
    fastcgi_read_timeout 3000s;
    fastcgi_send_timeout 3000s;
    fastcgi_param HTTPS $my_ssl;
    fastcgi_param REMOTE_ADDR $http_x_real_ip;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_param REMOTE_ADDR $http_x_real_ip;
}
}

据我检查,只有这几行:

upstream fastcgi_backend {
server   127.0.0.1:9000;
#server unix:/run/php/php7.2-fpm.sock;
}

我的网站坏了。有人能帮忙吗?

答案1

upstream fastcgi_backend定义了两次: inmysites.conf和 in wallpapershop.gr.conf.save。因此您收到错误消息nginx: [emerg] duplicate upstream "fastcgi_backend"

通过删除第二个配置文件(按照 Michael Hampton 的建议),您解决了这个问题。

相关内容