系统相关
首页 > 系统相关> > apt – 在Debian 8.4上将Nginx服务器更新为1.10

apt – 在Debian 8.4上将Nginx服务器更新为1.10

作者:互联网

我刚刚在虚拟机上安装了最新的Debian版本(8.4),一切都很顺利.

然后我从Debian repos安装了nginx服务器,我得到了1.6.2版本,而最新版本是1.10,所以我想更新它.

我尝试这样做的方式可能是错的,但这是我迄今为止所发现的全部内容.

我首先通过以下方式将nginx repo添加到sources.list文件来更新我的存储库:

$sudo sh -c "echo 'deb http://nginx.org/packages/debian/ `lsb_release -cs` nginx' >> /etc/apt/sources.list"
$sudo sh -c "echo 'deb-src http://nginx.org/packages/debian/ `lsb_release -cs` nginx' >> /etc/apt/sources.list"
$curl http://nginx.org/keys/nginx_signing.key | apt-key add -
$sudo apt-get update

然后,我尝试使用此命令安装最新的nginx版本:

$sudo apt-get install nginx

我得到了这个问题:

root@Debian:/#LANG=C apt-get install nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
    nginx-common nginx-full
Use 'apt-get autoremove' to remove them.
The following packages will be upgraded:
    nginx
1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/739 kB of archives.
After this operation, 2421 kB of additional disk space will be used.
Reading changelogs... Done
(Reading database ... 140333 files and directories currently installed.)
Preparing to unpack .../nginx_1.10.0-1~jessie_i386.deb ...
Unpacking nginx (1.10.0-1~jessie) over (1.6.2-5+deb8u1) ...
dpkg: error processing archive /var/cache/apt/archives/nginx_1.10.0-1~jessie_i386.deb (--unpack): trying to overwrite '/etc/default/nginx', which is also in package nginx-common 1.6.2-5+deb8u1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
    /var/cache/apt/archives/nginx_1.10.0-1~jessie_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我怎么解决这个问题?

解决方法:

基本错误是这个(强调我的):

dpkg: error processing archive /var/cache/apt/archives/nginx_1.10.0-1~jessie_i386.deb (–unpack): trying to overwrite ‘/etc/default/nginx’, which is also in package nginx-common 1.6.2-5+deb8u1

这意味着您正在安装的新软件包试图覆盖另一个软件包(您安装的nginx-common)提供的文件,而dpkg害怕会破坏内容并拒绝执行此操作.

简单的解决方案是完全删除nginx-common软件包,然后再次安装新版本:

sudo apt-get purge nginx-common
sudo apt-get install nginx

标签:dpkg,nginx,apt,package-management,software-installation
来源: https://codeday.me/bug/20190814/1652220.html