将 NGINX 从 debian-buster repo 更新为 nginx-repo

将 NGINX 从 debian-buster repo 更新为 nginx-repo

当我尝试将我的 nginx 版本(从 debian 存储库安装)更新为 nginx 存储库中的最新版本时,它会失败,因为它无法覆盖旧 nginx 软件包之一中的文件(该软件包即将被自动删除)。这是运行命令时的 bash 输出apt install nginx -V

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
   geoip-database (20190724-1~bpo10+1)
   libgd3 (2.2.5-5.2)
   libgeoip1 (1.6.12-3~bpo10+1)
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
   libnginx-mod-http-auth-pam (1.14.2-2)
   libnginx-mod-http-dav-ext (1.14.2-2)
   libnginx-mod-http-echo (1.14.2-2)
   libnginx-mod-http-geoip (1.14.2-2)
   libnginx-mod-http-image-filter (1.14.2-2)
   libnginx-mod-http-subs-filter (1.14.2-2)
   libnginx-mod-http-upstream-fair (1.14.2-2)
   libnginx-mod-http-xslt-filter (1.14.2-2)
   libnginx-mod-mail (1.14.2-2)
   libnginx-mod-stream (1.14.2-2)
   nginx-common (1.14.2-2)
   nginx-full (1.14.2-2)
The following packages will be upgraded:
   nginx (1.14.2-2 => 1.16.1-1~buster)
1 upgraded, 0 newly installed, 12 to remove and 0 not upgraded.
Need to get 0 B/850 kB of archives.
After this operation, 291 kB disk space will be freed.
Do you want to continue? [Y/n]
dpkg: libnginx-mod-http-auth-pam: dependency problems, but removing anyway as you requested:
 nginx-full depends on libnginx-mod-http-auth-pam (= 1.14.2-2).

(Reading database ... 152770 files and directories currently installed.)
Removing libnginx-mod-http-auth-pam (1.14.2-2) ...
dpkg: nginx-common: dependency problems, but removing anyway as you requested:
 nginx-full depends on nginx-common (= 1.14.2-2); however:
  Package nginx-common is to be removed.
 libnginx-mod-stream depends on nginx-common (= 1.14.2-2).
 libnginx-mod-mail depends on nginx-common (= 1.14.2-2).
 libnginx-mod-http-xslt-filter depends on nginx-common (= 1.14.2-2).
 libnginx-mod-http-upstream-fair depends on nginx-common (= 1.14.2-2).
 libnginx-mod-http-subs-filter depends on nginx-common (= 1.14.2-2).
 libnginx-mod-http-image-filter depends on nginx-common (= 1.14.2-2).
 libnginx-mod-http-geoip depends on nginx-common (= 1.14.2-2).
 libnginx-mod-http-echo depends on nginx-common (= 1.14.2-2).
 libnginx-mod-http-dav-ext depends on nginx-common (= 1.14.2-2).

Removing nginx-common (1.14.2-2) ...
(Reading database ... 152743 files and directories currently installed.)
Preparing to unpack .../nginx_1.16.1-1~buster_amd64.deb ...
Unpacking nginx (1.16.1-1~buster) over (1.14.2-2) ...
dpkg: error processing archive /var/cache/apt/archives/nginx_1.16.1-1~buster_amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/nginx', which is also in package nginx-full 1.14.2-2
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/nginx_1.16.1-1~buster_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

看起来它不是先卸载旧软件包,然后安装新软件包。而是先卸载两个软件包,然后尝试安装更新的软件包。因为尝试此更新后,我需要重新nginx-common安装libnginx-mod-http-auth-pam

我的问题是:有人知道强制新安装的方法吗(dist-upgrade--with-new-pkgs没有用)或者我是否需要手动卸载这些软件包?还是我只是错过了升级前要做的一步?

答案1

不知道这是否仍然相关,但我遇到了类似的问题。对我有用的是卸载了旧的 nginx:apt remove nginx nginx-common

然后安装新版本:apt install nginx

如果你当前的版本有问题,你可以使用以下方法修复apt --fix-broken install

答案2

使用此命令。这对我有用。

sudo dpkg --purge --force-depends apache2

相关内容