我刚刚在虚拟机上安装了最新的 Debian 版本(8.4),一切都很顺利。
然后我从 Debian 存储库安装了 nginx 服务器,得到的版本是 1.6.2,而最新的可用版本是 1.10,所以我想更新它。
我尝试做的方式可能是错误的,但这是我迄今为止所发现的。
sources.list
我首先通过以下方式将 nginx 存储库添加到文件中来更新我的存储库:
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)
我该如何解决这个问题?
答案1
基本错误是这样的(强调我的):
dpkg:处理存档 /var/cache/apt/archives/nginx_1.10.0-1~jessie_i386.deb 时出错(--unpack):尝试覆盖'/etc/default/nginx',它也在包 nginx-common 1.6.2-5+deb8u1 中
这意味着您正在安装的新软件包正在尝试覆盖另一个软件包(您安装的nginx-common
)提供的文件,并且dpkg
担心会破坏内容并拒绝这样做。
简单的解决方案是完全删除nginx-common
软件包,然后再次安装新版本:
sudo apt-get purge nginx-common
sudo apt-get install nginx