Debian 8.4 で Nginx サーバーを 1.10 にアップデートする

Debian 8.4 で Nginx サーバーを 1.10 にアップデートする

最新の Debian バージョン (8.4) を仮想マシンにインストールしたところ、すべて正常に動作しました。

その後、Debian リポジトリから nginx サーバーをインストールし、バージョン 1.6.2 を取得しましたが、利用可能な最新バージョンは 1.10 なので、更新したいと思います。

私が試した方法は間違っているかもしれませんが、今のところそれが私が見つけたすべてです。

まず、次のように nginx リポジトリをファイルに追加してリポジトリを更新しました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)

これをどうすれば解決できますか?

答え1

基本的な誤りは次のとおりです (強調は筆者による):

dpkg: アーカイブ /var/cache/apt/archives/nginx_1.10.0-1~jessie_i386.deb (--unpack) の処理中にエラーが発生しました:nginx-common 1.6.2-5+deb8u1 パッケージにも含まれる '/etc/default/nginx' を上書きしようとしています

これは、インストールする新しいパッケージが、別のパッケージ (インストール済みnginx-common) によって提供されるファイルを上書きしようとしており、dpkgそれが何かを壊すことを恐れてそれを拒否していることを意味します。

簡単な解決策は、nginx-commonパッケージを完全に削除してから、新しいバージョンを再度インストールすることです。

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

関連情報