debian 8.3 中的 Nginx 安装错误

Nginx installation errors in debian 8.3

Setting up nginx-full (1.6.2-5+deb8u1) ...
Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
invoke-rc.d: initscript nginx, action "start" failed.
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.6.2-5+deb8u1) | nginx-light (>= 1.6.2-5+deb8u1) | nginx-extras (>= 1.6.2-5+deb8u1); 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.6.2-5+deb8u1.1~) | nginx-light (<< 1.6.2-5+deb8u1.1~) | nginx-extras (<< 1.6.2-5+deb8u1.1~); however:
 Package nginx-full is not configured yet.
 Package nginx-light is not installed.
 Package nginx-extras is not installed.

dpkg: error processing package nginx (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.19-18+deb8u3) ...
Processing triggers for systemd (215-17+deb8u3) ...
Errors were encountered while processing:
 nginx-full
 nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)

以上是运行sudo apt-get install nginx时给我的错误。我尝试删除 apache 和 nginx 并重新安装,但它给出了同样的错误。

对我有帮助:

service apache2 stop
apt-get remove apache2*
apt-get autoremove

你没有 post systemctl status nginx.service 的输出,所以这可能不对,但我有这个问题是因为我忘记了旧安装的 nginx。

所以,我清除了 nginx 并重新安装:

    apt-get purge nginx-full nginx-common
    apt-get install nginx-full

然后我收到另一个错误,得到了详细信息:systemctl status nginx.service

就我而言

nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

所以我有另一个 Web 服务器在端口 80 上侦听。

为了修复,我编辑了默认的 nginx 站点 nano /etc/nginx/sites-available/default 并删除了在端口 80 上的侦听。

我只需要 SSL,所以:

    server {
        listen 443 ssl;
        //rest of config....
    }

我遇到了同样的问题。 我没有 Apache,也没有其他东西阻止我的 80 端口。 我无法使用

安装 nginx
sudo apt-get install nginx

也不与

sudo apt-get install nginx-common nginx-full

一周后我偶然发现了这个小博客:https://etc.banana.fish/?p=75

在这篇博客中,解决方案是:

  1. 安装 nginx-common:sudo apt-get install nginx-common
  2. /etc/nginx/sites-enabled/default 中删除 listen [::]:80 default_server;(我使用 root 用户创建的)
  3. 为了确定,我确实重启了我的服务器。
  4. 为了确定两次,我做了 sudo apt-get update,然后 sudo apt-get upgrade
  5. 现在我终于调用了 sudo apt-get install nginx-full 并且成功了!

输入远程服务器的IP后,我可以看到nginx的Titlescreen了!

我在 ubuntu16 Amazon EC2 实例上安装 nginx 时遇到了类似的问题,原因似乎是我在安全组设置下摆弄了入站端口 理想情况下,它们应该是: HTTP TCP 80 0.0.0.0/0 和

HTTP TCP 80 ::/0

由于某种原因,我错误地删除了其中一个,当我修复所有内容时,它出现了