我从 14.04 服务器升级到了 16.04 服务器。我一直使用官方的 nginx 软件包,因为我需要支持 SPDY 和 HTTP2 等功能,而 14.04 版的 nginx 并不支持这些功能。现在,当我尝试更新时,我收到以下错误消息。
Preparing to unpack .../nginx_1.11.1-1~xenial_amd64.deb ...
Unpacking nginx (1.11.1-1~xenial) over (1.10.0-0ubuntu0.16.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/nginx_1.11.1-1~xenial_amd64.deb (--unpack):
trying to overwrite '/usr/share/nginx/html/index.html', which is also in package nginx-common 1.10.0-0ubuntu0.16.04.2
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/nginx_1.11.1-1~xenial_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Failed to perform requested operation on package. Trying to recover:
在我的 sources.list 文件中我有:
deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx
有什么想法可以解决这个问题吗?
答案1
这可能会解决问题。我自己也遇到过这个问题,还有其他几个问题。
移动到 /etc 并复制 nginx 目录以确保安全:
cd /etc cp -R nginx/ nginx-bak/
删除旧版本的nginx:
apt-get remove nginx nginx-common
安装新的 nginx:
apt-get install nginx
- 对于任何覆盖配置的提示,请回答否。
要启用并运行 nginx:
systemctl unmask nginx.service systemctl start nginx.service