在 Debian 8.4 上將 Nginx 伺服器更新到 1.10

在 Debian 8.4 上將 Nginx 伺服器更新到 1.10

我剛剛在虛擬機器上安裝了最新的 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

相關內容