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):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

おすすめ記事