Closed6

Nginx cannot upgrade at Ubuntu 22.04.3

ピン留めされたアイテム
at yasuat yasu

まとめ的な

nginx の更新をしたかったが、競合エラーが出るため、とりあえず再インストールをした。

再インストールの実行には日本語環境ではコケるので、英語環境にした。今回は LANG だけを切り替えたが、インストールスクリプトのperlがうるさいので LC_CTYPEen_US.UTF-8 にした方がいい。

今回は nginx 1.18.2 → 1.25 に上げたので、quic 対応やら http2 の指定変更があります。ただ quic は別に対応しなくてもいいので、http2 の変更のみした。 see : NGINX Plus R30の発表 -- www.nginx.co.jp

LANG=ja_JP.UTF-8 では競合エラーが出て、LANG=en_US.UTF-8 では通る理由は不明。

at yasuat yasu

何が起きた?

Nginx を apt で Upgrade しようとしたら競合が出てアップグレードできなくなった。

対処・対応は?

  1. LC_LANG を en_US.UTF-8 にして、再インストールをした。
  2. nginx の設定変更箇所があるので変更をして再起動。
at yasuat yasu

何が起きた?

nginx 1.18 が入っている状態からアップグレードをしようとしたら、コケた。

まずアップグレードリストを見る。

ubuntu@ほすとなの:~$ apt list --upgradable
一覧表示... 完了
libnginx-mod-http-geoip2/jammy-updates 1.18.0-6ubuntu14.4 amd64 [1.18.0-6ubuntu14.3 からアップグレード可]
libnginx-mod-http-image-filter/jammy-updates 1.18.0-6ubuntu14.4 amd64 [1.18.0-6ubuntu14.3 からアップグレード可] 
libnginx-mod-http-xslt-filter/jammy-updates 1.18.0-6ubuntu14.4 amd64 [1.18.0-6ubuntu14.3 からアップグレード可]
libnginx-mod-mail/jammy-updates 1.18.0-6ubuntu14.4 amd64 [1.18.0-6ubuntu14.3 からアップグレード可]
libnginx-mod-stream-geoip2/jammy-updates 1.18.0-6ubuntu14.4 amd64 [1.18.0-6ubuntu14.3 からアップグレード可]
libnginx-mod-stream/jammy-updates 1.18.0-6ubuntu14.4 amd64 [1.18.0-6ubuntu14.3 からアップグレード可]
nginx-common/jammy-updates 1.18.0-6ubuntu14.4 all [1.18.0-6ubuntu14.3 からアップグレード可]
nginx-core/jammy-updates 1.18.0-6ubuntu14.4 amd64 [1.18.0-6ubuntu14.3 からアップグレード可]
nginx/stable 1.25.3-1~jammy amd64 [1.18.0-6ubuntu14.3 からアップグレード可]

色々あったが、nginx がある。こいつだけをアップグレードをさせようと指定するとコケる。他のパッケージは普通に sudo apt upgrade で通った。

ubuntu@ほすとなの:~$ sudo apt upgrade nginx nginx-common
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
状態情報を読み取っています... 完了        
アップグレードパッケージを検出しています... 完了
インストールすることができないパッケージがありました。おそらく、あり得
ない状況を要求したか、(不安定版ディストリビューションを使用しているの
であれば) 必要なパッケージがまだ作成されていなかったり Incoming から移 
動されていないことが考えられます。
以下の情報がこの問題を解決するために役立つかもしれません:

以下のパッケージには満たせない依存関係があります:
 nginx : 競合: nginx-common しかし、1.18.0-6ubuntu14.4 はインストールされようとしています
E: 壊れたパッケージ 
at yasuat yasu

対処・対応

普通に apt install --reinstall nginx nginx-common ではコケる。

ubuntu@ほすとなの:~$ sudo apt install --reinstall nginx nginx-common
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
状態情報を読み取っています... 完了        
インストールすることができないパッケージがありました。おそらく、あり得
ない状況を要求したか、(不安定版ディストリビューションを使用しているの
であれば) 必要なパッケージがまだ作成されていなかったり Incoming から移 
動されていないことが考えられます。 
以下の情報がこの問題を解決するために役立つかもしれません:

以下のパッケージには満たせない依存関係があります:
 nginx : 競合: nginx-common しかし、1.18.0-6ubuntu14.4 はインストールされようとしています
E: 問題を解決することができません。壊れた変更禁止パッケージがあります。

なんとなく、日本語訳されていると読みにくいので、環境変数の LANG を英語にして再インストールをした。なお、LANG を日本語のまま( ja_JP.UTF-8)だとインストールに失敗する。なぜかは知らん。

ubuntu@ホストなの:~$ sudo apt install --reinstall nginx nginx-common
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
状態情報を読み取っています... 完了        
インストールすることができないパッケージがありました。おそらく、あり得
ない状況を要求したか、(不安定版ディストリビューションを使用しているの
であれば) 必要なパッケージがまだ作成されていなかったり Incoming から移 
動されていないことが考えられます。 
以下の情報がこの問題を解決するために役立つかもしれません:

以下のパッケージには満たせない依存関係があります:
 nginx : 競合: nginx-common しかし、1.18.0-6ubuntu14.4 はインストールされようとしています
E: 問題を解決することができません。壊れた変更禁止パッケージがあります。

英語に切り替えて再インストールをして成功した様子。

ubuntu@ほすとなの:~$ echo $LANG
ja_JP.UTF-8
ubuntu@ほすとなの:~$ export LANG='en_US.UTF-8'

ubuntu@ほすとなの:~$ sudo apt install --reinstall nginx-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libnginx-mod-http-geoip2 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
  libnginx-mod-stream-geoip2 nginx-core
Suggested packages:
  fcgiwrap nginx-doc
The following packages will be REMOVED:
  nginx
The following packages will be upgraded:
  libnginx-mod-http-geoip2 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
  libnginx-mod-stream-geoip2 nginx-common nginx-core
8 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Need to get 693 kB of archives.
After this operation, 50.2 kB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 nginx-core amd64 1.18.0-6ubuntu14.4 [484 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-stream-geoip2 amd64 1.18.0-6ubuntu14.4 [10.1 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-stream amd64 1.18.0-6ubuntu14.4 [72.9 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-mail amd64 1.18.0-6ubuntu14.4 [45.7 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-xslt-filter amd64 1.18.0-6ubuntu14.4 [13.7 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-geoip2 amd64 1.18.0-6ubuntu14.4 [11.9 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-image-filter amd64 1.18.0-6ubuntu14.4 [15.4 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 nginx-common all 1.18.0-6ubuntu14.4 [40.0 kB]
Fetched 693 kB in 2s (370 kB/s)       
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "ja_JP.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Preconfiguring packages ...
(Reading database ... 132474 files and directories currently installed.)
Removing nginx (1.18.0-6ubuntu14.3) ...
(Reading database ... 132473 files and directories currently installed.)
Preparing to unpack .../0-nginx-core_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking nginx-core (1.18.0-6ubuntu14.4) over (1.18.0-6ubuntu14.3) ...
Preparing to unpack .../1-libnginx-mod-stream-geoip2_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-stream-geoip2 (1.18.0-6ubuntu14.4) over (1.18.0-6ubuntu14.3) ...
Preparing to unpack .../2-libnginx-mod-stream_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-stream (1.18.0-6ubuntu14.4) over (1.18.0-6ubuntu14.3) ...
Preparing to unpack .../3-libnginx-mod-mail_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-mail (1.18.0-6ubuntu14.4) over (1.18.0-6ubuntu14.3) ...
Preparing to unpack .../4-libnginx-mod-http-xslt-filter_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-http-xslt-filter (1.18.0-6ubuntu14.4) over (1.18.0-6ubuntu14.3) ...
Preparing to unpack .../5-libnginx-mod-http-geoip2_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-http-geoip2 (1.18.0-6ubuntu14.4) over (1.18.0-6ubuntu14.3) ...
Preparing to unpack .../6-libnginx-mod-http-image-filter_1.18.0-6ubuntu14.4_amd64.deb ...
Unpacking libnginx-mod-http-image-filter (1.18.0-6ubuntu14.4) over (1.18.0-6ubuntu14.3) ...
Preparing to unpack .../7-nginx-common_1.18.0-6ubuntu14.4_all.deb ...
Unpacking nginx-common (1.18.0-6ubuntu14.4) over (1.18.0-6ubuntu14.3) ...
Setting up nginx-common (1.18.0-6ubuntu14.4) ...
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up libnginx-mod-http-xslt-filter (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-http-geoip2 (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-mail (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-http-image-filter (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-stream (1.18.0-6ubuntu14.4) ...
Setting up libnginx-mod-stream-geoip2 (1.18.0-6ubuntu14.4) ...
Setting up nginx-core (1.18.0-6ubuntu14.4) ...
 * Upgrading binary nginx                                                                                                         [ OK ] 
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for ufw (0.36.1-4ubuntu0.1) ...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "ja_JP.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "ja_JP.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "ja_JP.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Scanning processes...                                                                                                                    
Scanning linux images...                                                                                                                 

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.


これだけでは nginx-common しか入っていないので、本体が入っている nginx も入れる必要がある。

ubuntu@ik1-422-43464:~$ sudo apt --fix-broken install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  libnginx-mod-http-geoip2 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
  libnginx-mod-stream-geoip2 nginx-common nginx-core
The following NEW packages will be installed:
  nginx
0 upgraded, 1 newly installed, 8 to remove and 0 not upgraded.
Need to get 1133 kB of archives.
After this operation, 1323 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://nginx.org/packages/mainline/ubuntu jammy/nginx amd64 nginx amd64 1.25.3-1~jammy [1133 kB]
Fetched 1133 kB in 4s (314 kB/s)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "ja_JP.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 132471 files and directories currently installed.)
Removing nginx-core (1.18.0-6ubuntu14.4) ...
Removing libnginx-mod-http-geoip2 (1.18.0-6ubuntu14.4) ...
Removing libnginx-mod-http-image-filter (1.18.0-6ubuntu14.4) ...
Removing libnginx-mod-http-xslt-filter (1.18.0-6ubuntu14.4) ...
Removing libnginx-mod-mail (1.18.0-6ubuntu14.4) ...
Removing libnginx-mod-stream-geoip2 (1.18.0-6ubuntu14.4) ...
Removing libnginx-mod-stream (1.18.0-6ubuntu14.4) ...
Removing nginx-common (1.18.0-6ubuntu14.4) ...
Selecting previously unselected package nginx.
(Reading database ... 132413 files and directories currently installed.)
Preparing to unpack .../nginx_1.25.3-1~jammy_amd64.deb ...
----------------------------------------------------------------------
Thanks for using nginx!

Please find the official documentation for nginx here:
* https://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* https://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* https://nginx.com/products/

----------------------------------------------------------------------
Unpacking nginx (1.25.3-1~jammy) ...
Setting up nginx (1.25.3-1~jammy) ...
Installing new version of config file /etc/default/nginx ...
Installing new version of config file /etc/init.d/nginx ...

Configuration file '/etc/logrotate.d/nginx'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nginx (Y/I/N/O/D/Z) [default=N] ? 
Installing new version of config file /etc/nginx/fastcgi_params ...
Installing new version of config file /etc/nginx/mime.types ...

Configuration file '/etc/nginx/nginx.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nginx.conf (Y/I/N/O/D/Z) [default=N] ? 
Processing triggers for man-db (2.10.2-1) ...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "ja_JP.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "ja_JP.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "ja_JP.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Scanning processes...                                                                                                                    
Scanning linux images...                                                                                                                 

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

設定の変更箇所がないか確認をする。一箇所だけ変更箇所があるので変更をしてやる(後述)

ubuntu@ホストなの:~$ sudo nginx -t
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/conf.d/virtual.conf:50
nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

あとは起動をしてやる。インストールしたばかりの時は起動しないため。

ubuntu@ほすとなの:~$ sudo systemctl start nginx                                                                                       
at yasuat yasu

:think: んー、てか、nginx と nginx-common が入ってるのは何故だ。

nginx-common は 1.18.0-6ubuntu14.4 で、nginx は 1.25.3-1~jammy だ。LaunchPad を見ると 1.24 が今のところ(2023/11/20)最新になっている。 nginx -- launchpad.net
これが原因じゃね…?

at yasuat yasu

あー、nginx-common 入ってない、だからか。なるほど。使わないならいらないな…

このスクラップは6ヶ月前にクローズされました