当前位置: 首页>>技术问答>>正文


Ubuntu 16.04中的Nginx安装错误

, , , , ,

问题描述


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

Reading package lists... Done
Building dependency tree       
Reading state information... Done

After this operation, 5,579 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get: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]
Fetched 3,789 kB in 33s (112 kB/s)                                             
Selecting previously unselected package nginx-common.
(Reading database ... 189767 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.10.0-0ubuntu0.16.04.1_all.deb ...
Unpacking nginx-common (1.10.0-0ubuntu0.16.04.1) ...
Selecting previously unselected package nginx-full.
Preparing to unpack .../nginx-full_1.10.0-0ubuntu0.16.04.1_amd64.deb ...
Unpacking nginx-full (1.10.0-0ubuntu0.16.04.1) ...
Selecting previously unselected package nginx-full-dbg.
Preparing to unpack .../nginx-full-dbg_1.10.0-0ubuntu0.16.04.1_amd64.deb ...
Unpacking nginx-full-dbg (1.10.0-0ubuntu0.16.04.1) ...
Processing triggers for ufw (0.35-0ubuntu1) ...
Rules updated for profile 'Apache Full'
Rules updated for profile 'Nginx HTTP'

Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up nginx-common (1.10.0-0ubuntu0.16.04.1) ...
Setting up nginx-full (1.10.0-0ubuntu0.16.04.1) ...
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" 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-full-dbg:
 nginx-full-dbg depends on nginx-full (= 1.10.0-0ubuntu0.16.04.1); however:
  Package nginx-full is not configured yet.

dpkg: error processing package nginx-full-dbg (--configure):

 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.

                          Errors were encountered while processing:
 nginx-full

 nginx-full-dbg

E: Sub-process /usr/bin/dpkg returned an error code (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

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/6421.html,未经允许,请勿转载。