Ubuntu 16.04中的Nginx安装错误

 :〜$ sudo apt-get remove nginx * && sudo apt-get install nginx-full *

阅读包裹清单......完成
构建依赖树       
阅读国家信息......完成

在此操作之后,将使用5,579 kB的额外磁盘空间。
你想继续吗?  [是/否] y
获取:1 http://in.archive.ubuntu.com/ubuntu xenial-updates / universe amd64 nginx-full-dbg amd64 1.10.0-0ubuntu0.16.04.1 [3,789 kB]
以33s(112 kB / s)提取3,789 kB                                             
选择以前未选择的包nginx-common。
 (读取数据库...当前安装的189767个文件和目录。)
准备打开... / nginx-common_1.10.0-0ubuntu0.16.04.1_all.deb ...
解包nginx-common(1.10.0-0ubuntu0.16.04.1)...
选择以前未选择的包nginx-full。
准备拆包... / nginx-full_1.10.0-0ubuntu0.16.04.1_amd64.deb ...
解包nginx-full(1.10.0-0ubuntu0.16.04.1)...
选择以前未选择的包nginx-full-dbg。
准备打开... / nginx-full-dbg_1.10.0-0ubuntu0.16.04.1_amd64.deb ...
解包nginx-full-dbg(1.10.0-0ubuntu0.16.04.1)...
处理ufw的触发器(0.35-0ubuntu1)......
更新了配置文件'Apache Full'的规则
更新了配置文件'Nginx HTTP'的规则

 systemd的处理触发器(229-4ubuntu4)......
处理ureadahead的触发器(0.100.0-19)......
处理man-db的触发器(2.7.5-1)......
设置nginx-common(1.10.0-0ubuntu0.16.04.1)......
设置nginx-full(1.10.0-0ubuntu0.16.04.1)......
 nginx.service的作业失败,因为控制进程退出并显示错误代码。 有关详细信息,请参阅“systemctl status nginx.service”和“journalctl -xe”。

 invoke-rc.d:initscript nginx,action“start”失败。

 dpkg:error handling包nginx-full( -  configure):
 安装后的子进程安装后脚本返回错误退出状态1
 dpkg:依赖性问题会阻止nginx-full-dbg的配置:
  nginx-full-dbg取决于nginx-full(= 1.10.0-0ubuntu0.16.04.1); 然而:
  尚未配置包nginx-full。

 dpkg:error handling包nginx-full-dbg( -  configure):

 依赖性问题 - 保持未配置状态
没有写入apport报告,因为错误消息表明它是先前故障的后续错误。

                          处理时遇到错误:
  nginx的全

  nginx的 - 全DBG

 E:子进程/ usr / bin / dpkg返回错误代码(1)

在安装nginx之前首先关闭apache2应解决此问题:

 sudo service apache2 stop 

Andrew Chan为我提供了正确的答案。 为了扩展他的答案,这是你可以在命令行上做的事情;

停止apache2

sudo systemctl stop apache2.service

防止apache2在启动时启动

sudo systemctl disable apache2.service

重新安装nginx

sudo apt-get install nginx

我刚遇到这个问题,但解决方案略有不同。

一旦我解决了一个简单的站点错误配置,我就能够更新nginx。

检查你的nginx错误日志

sudo cat /var/log/nginx/error.log|less

然后再试一次:

sudo apt-get update; sudo apt-get upgrade

在我的情况下,错误是服务器已禁用IPv6。 解:

编辑/etc/nginx/sites-enabled/default并注释掉IPv6:

 listen [::]:80 default_server; 

重新安装nginx:

 apt purge nginx apt autoremove apt install nginx 

当我检查/var/log/nginx/error.log时,我看到安装程序无法打开/ var / cache / nginx / microcache

目录列表显示没有/ var / cache / nginx目录,因此我创建了它并且安装成功。

在安装之前,从/sites-enabled删除所有手动添加的符号链接。