CVE-2022-38023適用後 NetAppがActive Directoryに参加できない

いままでも「SMB2 Enabled for DC Connections設定に起因する接続できない問題」というのがあったが、先日話題になった「Active Directoryサーバのセキュリティ強化アップデート(CVE-2022-38023)に伴うONTAPファイルサーバへの影響」で、2023年7月以降のActive Directory環境ではONTAP をCIFSに新規作成しようとした場合にエラーがでる、という問題が出ていた。

Is AES Encryption Enabled設定」と「AES session key enabled for NetLogon channel設定」の2つの設定を変更する必要がある。

前者はONTAP 9.12.1から初期値変更、後者はONTAP 9.10.1から初期値変更となっているので、最近導入している場合は問題が発生しないのだが、以前のバージョンからアップデートしているような環境の場合は以前の値のままとなっているため注意が必要となっている。

その1: Is AES Encryption Enabled 設定

以前からONTAPを使っていてアップデートしているような環境では、SMB内部接続での暗号化形式でAESを使わない、という設定になっているせいで、下記の様なエラーとなる。

netapp9101::> vserver cifs create -vserver svm3 -cifs-server svm3 -domain adosakana.local

In order to create an Active Directory machine account for the CIFS server, you must supply the name and password of a Windows account with
sufficient privileges to add computers to the "CN=Computers" container within the "ADOSAKANA.LOCAL" domain.

Enter the user name: administrator

Enter the password:

Error: Machine account creation procedure failed
  [    47] Loaded the preliminary configuration.
  [   130] Created a machine account in the domain
  [   130] SID to name translations of Domain Users and Admins
           completed successfully
  [   131] Successfully connected to ip 172.17.44.49, port 88 using
           TCP
  [   142] Successfully connected to ip 172.17.44.49, port 464 using
           TCP
  [   233] Kerberos password set for 'SVM3$@ADOSAKANA.LOCAL' succeeded
  [   233] Set initial account password
  [   244] Successfully connected to ip 172.17.44.49, port 445 using
           TCP
  [   276] Successfully connected to ip 172.17.44.49, port 88 using
           TCP
  [   311] Successfully authenticated with DC
           adserver.adosakana.local
  [   324] Unable to connect to NetLogon service on
           adserver.adosakana.local (Error:
           RESULT_ERROR_GENERAL_FAILURE)
**[   324] FAILURE: Unable to make a connection
**         (NetLogon:ADOSAKANA.LOCAL), result: 3
  [   324] Unable to make a NetLogon connection to
           adserver.adosakana.local using the new machine account
  [   346] Deleted existing account
           'CN=SVM3,CN=Computers,DC=adosakana,DC=local'

Error: command failed: Failed to create the Active Directory machine account "SVM3". Reason: general failure.

netapp9101::>

この問題はマニュアルの「Enable or disable AES encryption for Kerberos-based communication」に記載されているように「is-aes-encryption-enabled」設定をtrueに変更することで解決する。

netapp9101::> vserver cifs security modify -vserver svm3 -is-aes-encryption-enabled true
netapp9101::> vserver cifs security show -fields is-aes-encryption-enabled
vserver is-aes-encryption-enabled
------- -------------------------
Cluster -
Snapmirror-WAN
        -
netapp9101
        -
netapp9101-01
        -
svm0    true
svm2    false
svm3    true
7 entries were displayed.

netapp9101::>

その2: AES session key enabled for NetLogon channel 設定

上記を設定しても、下記の様なエラーとなった。

netapp9101::> vserver cifs create -vserver svm3 -cifs-server svm3 -domain vm2.adosakana.local

In order to create an Active Directory machine account for the CIFS server, you must supply the name and password of
a Windows account with sufficient privileges to add computers to the "CN=Computers" container within the
"ADOSAKANA.LOCAL" domain.

Enter the user name: administrator

Enter the password:

Error: Machine account creation procedure failed
  [    43] Loaded the preliminary configuration.
  [   133] Created a machine account in the domain
  [   133] SID to name translations of Domain Users and Admins
           completed successfully
  [   134] Successfully connected to ip 172.17.44.49, port 88 using
           TCP
  [   144] Successfully connected to ip 172.17.44.49, port 464 using
           TCP
  [   226] Kerberos password set for 'SVM3$@ADOSAKANA.LOCAL' succeeded
  [   226] Set initial account password
  [   253] Successfully connected to ip 172.17.44.49, port 445 using
           TCP
  [   284] Successfully connected to ip 172.17.44.49, port 88 using
           TCP
  [   316] Successfully authenticated with DC
           adserver.adosakana.local
  [   323] Encountered NT error (NT_STATUS_PENDING) for SMB command
           Read
  [   327] Unable to connect to NetLogon service on
           adserver.adosakana.local (Error:
           RESULT_ERROR_GENERAL_FAILURE)
**[   327] FAILURE: Unable to make a connection
**         (NetLogon:ADOSAKANA.LOCAL), result: 3
  [   327] Unable to make a NetLogon connection to
           adserver.adosakana.local using the new machine account
  [   344] Deleted existing account
           'CN=SVM3,CN=Computers,DC=ADOSAKANA,DC=local'

Error: command failed: Failed to create the Active Directory machine account "SVM3". Reason: general failure.

netapp9101::>

この状況となった環境のActive Directoryサーバはsambaで作成しているため /usr/local/samba/var/log.samba を確認してみると下記のエラーがでていた。

[2023/10/20 14:48:22.301935,  0] ../../source4/rpc_server/netlogon/dcerpc_netlogon.c:281(dcesrv_netr_ServerAuthenticate3_check_downgrade)
  CVE-2022-38023: client_account[SVM3$] computer_name[SVM3] schannel_type[2] client_negotiate_flags[0x741ff] real_account[SVM3$] NT_STATUS_DOWNGRADE_DETECTED reject_des[0] reject_md5[1]
[2023/10/20 14:48:22.302215,  0] ../../source4/rpc_server/netlogon/dcerpc_netlogon.c:291(dcesrv_netr_ServerAuthenticate3_check_downgrade)
  CVE-2022-38023: Check if option 'server reject md5 schannel:SVM3$ = no' might be needed for a legacy client.
[2023/10/20 14:48:22.304539,  0] ../../source4/rpc_server/netlogon/dcerpc_netlogon.c:281(dcesrv_netr_ServerAuthenticate3_check_downgrade)
  CVE-2022-38023: client_account[SVM3$] computer_name[SVM3] schannel_type[2] client_negotiate_flags[0x701ff] real_account[SVM3$] NT_STATUS_DOWNGRADE_DETECTED reject_des[1] reject_md5[1]
[2023/10/20 14:48:22.304600,  0] ../../source4/rpc_server/netlogon/dcerpc_netlogon.c:291(dcesrv_netr_ServerAuthenticate3_check_downgrade)
  CVE-2022-38023: Check if option 'server reject md5 schannel:SVM3$ = no' might be needed for a legacy client.
[2023/10/20 14:48:22.304638,  0] ../../source4/rpc_server/netlogon/dcerpc_netlogon.c:298(dcesrv_netr_ServerAuthenticate3_check_downgrade)
  CVE-2022-38023: Check if option 'allow nt4 crypto:SVM3$ = yes' might be needed for a legacy client.

もしやkerneberosではなくNTLMで接続されてたりする?と lm-compatibility-level をkrb に設定しても同じ結果となった。

netapp9101::> vserver cifs security modify -vserver svm3 -lm-compatibility-level krb

netapp9101::> vserver cifs security show -fields lm-compatibility-level
vserver lm-compatibility-level
------- ----------------------
Cluster -
Snapmirror-WAN -
netapp9101 -
netapp9101-01 -
svm0    lm-ntlm-ntlmv2-krb
svm2    lm-ntlm-ntlmv2-krb
svm3    krb
7 entries were displayed.

netapp9101::>

さらに調べると「Configure Active Directory domain controller access overview」に、Netlogon にAESを使いたい場合は「aes-enabled-for-netlogon-channel」をtrueに設定する、と書いてあった

netapp9101::> vserver cifs security show -fields aes-enabled-for-netlogon-channel
vserver aes-enabled-for-netlogon-channel
------- --------------------------------
Cluster -
Snapmirror-WAN -
netapp9101 -
netapp9101-01 -
svm0    false
svm2    false
svm3    false
7 entries were displayed.

netapp9101::> vserver cifs security modify -vserver svm3 -aes-enabled-for-netlogon-channel true

netapp9101::> vserver cifs security show -fields aes-enabled-for-netlogon-channel
vserver aes-enabled-for-netlogon-channel
------- --------------------------------
Cluster -
Snapmirror-WAN -
netapp9101 -
netapp9101-01 -
svm0    false
svm2    false
svm3    true
7 entries were displayed.

netapp9101::>

設定変更後に再実行したところ、Active Directory参加に成功した。

netapp9101::> vserver cifs create -vserver svm3 -cifs-server svm3 -domain adosakana.local

In order to create an Active Directory machine account for the CIFS server, you must supply the name and password of
a Windows account with sufficient privileges to add computers to the "CN=Computers" container within the
"ADOSAKANA.LOCAL" domain.

Enter the user name: administrator

Enter the password:

Notice: SMB1 protocol version is obsolete and considered insecure. Therefore it is deprecated and disabled on this
CIFS server. Support for SMB1 might be removed in a future release. If required, use the (privilege: advanced)
"vserver cifs options modify -vserver svm3 -smb1-enabled true" to enable it.

netapp9101::>

↑のSMB1を有効にするかどうか、というところについては、複合機の出力先として指定されている、とか、LinuxサーバからCIFSでマウントしている、とか、Windowsワークグループからアクセスしている、という場合には有効にする、というような形となる。

Windows Server 2012R2に .Net Framework 3.5が追加できない場合の解決方法

実験するためWindows Server 2012R2を新規インストールして、まずはWindows Updateを全部適用してから、いろいろ設定していこう!と行ってみたところ思わぬところで問題が発生した。

結論を先に書いておくと「.NET Framework 3.5, 4.6.1, 4.7, 4.7.1, 4.7.2, 4.8 のセキュリティおよび品質ロールアップ」がインストールされていることが原因であるため

・Windows Updateを実施する前に追加すれば問題は発生しない
・Windows Update完了後に問題が発生した場合は「.NET Framework 3.5, 4.6.1, 4.7, 4.7.1, 4.7.2, 4.8 のセキュリティおよび品質ロールアップ」をアンインストールする

のどちらかを行うことで、インストールに成功するようになった。

ただ、.NET Frameworkのパッチの内部的な仕組みに気がつかないとアンインストールできないので、原因が知られていない、という状態でした。

問題の検証

Windows Updateが一通り終わったあとで、今回の実験対象のソフトウェアは.NET Framework 3.5が必要だな、と追加しようとしたらエラーとなった。

「代替ソースパスを指定」からDVD内のsources\sxs\を指定

で、エラー

このとき、イベントログのWindowsログの「Setup」に「パッケージ Microsoft .NET Framework 3.0の更新 NetFx3 を有効にできませんでした。 状態 0x800f0906。」と出ている

「0x800f0906」で調べると「.NET Framework 3.5 の展開エラーと解決手順」が出てくるが、コレではなかった。

[MS14-046] Windows 8.1 および Windows Server 2012 R2 用の .NET Framework 3.5 のセキュリティ更新プログラムについて (2014 年 8 月 12 日)」に以下の記載がある

Microsoft .NET Framework 3.5 用のセキュリティ更新プログラム 2966828 (マイクロソフト セキュリティ情報 MS14-046 に記載されています) をインストールした後、[Windows の機能] で Microsoft .NET Framework 3.5 のオプションの機能を初めて有効にしようとしたときに、機能がインストールされないことがあります。Microsoft .NET Framework 3.5 の機能を追加する前にインストールを “段階的に実行” した場合にこのエラーが発生することがあります。
この問題を解決するには、更新プログラム 3005628 をインストールします。
この問題を回避する方法の詳細については、以下のサポート技術情報番号をクリックしてください。
3002547Windows 8、Windows Server 2012、Windows 8.1、または Windows Server 2012 R2 でセキュリティ更新プログラム 2966827 または 2966828 をインストールした後に Microsoft .NET Framework 3.5 のオプションの Windows 機能を有効化できないことがある

更新プログラム 3005628「Windows 8、Windows 8.1、Windows Server 2012、および Windows Server 2012 R2 上の .NET Framework 3.5 の更新プログラム」の説明を読むと、原因としては、.NET Framework 3.5がインストールされていないのに、.NET Framework 3.5に関する更新プログラムがインストールされていることが原因である模様。

しかし、2023年9月現在では更新プログラム3005628 を適用してみたが効力はなかった。

更新履歴をみると「.NET Framework 3.5, 4.6.1, 4.7, 4.7.1, 4.7.2, 4.8 のセキュリティおよび品質ロールアップ」がある。

しかし、インストールされた更新プログラムを確認すると、.NET Framework関連のパッチがないのでインストールできないように見える。

ただ、調べたところwusaコマンドを使うとアンインストールできそうな感じだったので「wusa /uninstall /kb:5030184」でアンインストールを試みたが「インストールされていない」と表示される。

2023 年 9 月 12 日 – Windows Server 2012 R2 用 .NET Framework 3.5、4.6.2、4.7、4.7.1、4.7.2、4.8 のセキュリティおよび品質ロールアップ (KB5030184)」を確認すると、実はこの更新プログラム「Windows Server 2012 R2 用 .NET Framework 3.5 のセキュリティおよび品質ロールアップについて (KB5029915)」「Windows Server 2012 R2 用 .NET Framework 4.6.2、4.7、4.7.1、4.7.2 のセキュリティおよび品質ロールアップについて (KB5029916)」「Windows Server 2012 R2 用 .NET Framework 4.8 のセキュリティおよび品質ロールアップについて (KB5029917)」の3本だてらしい。

更新履歴上にこの3つは載ってないけど、試してみるかと「wusa /uninstall /kb:5029915」を実行すると、アンインストールに成功した。

おや?と思って、先ほどのインストールされた更新プログラム画像を再確認するとKB5029915がいた・・・

なるほど・・・「更新履歴」と「インストールされた更新プログラム」とで表示されるKB番号が別なのか・・・

で・・・これで大丈夫かな?と、.Net 3.5追加を試してみたらエラーになった。

もう一度更新一覧を確認しなおすともう1つ「.NET Framework 3.5, 4.6.1, 4.7, 4.7.1, 4.7.2, 4.8 のセキュリティおよび品質ロールアップ」があった

そちらは「2023 年 8 月 8 日 – Windows Server 2012 R2 用 .NET Framework 3.5、4.6.2、4.7、4.7.1、4.7.2、4.8 のセキュリティおよび品質ロールアップ (KB5029653)」で、「Windows Server 2012 R2 用 .NET Framework 3.5 のセキュリティおよび品質ロールアップについて (KB5028970)」「Windows Server 2012 R2 用 .NET Framework 4.6.2、4.7、4.7.1、4.7.2 のセキュリティおよび品質ロールアップについて (KB5028962)」「Windows Server 2012 R2 用 .NET Framework 4.8 のセキュリティおよび品質ロールアップについて (KB5028957)」なので、「wusa /uninstall /kb:5028970」でアンインストールを実行。

もしくは「インストールされた更新プログラム」から「Microsoft Windows (KB5028970)の更新プログラム」を右クリックして「アンインストール」でも大丈夫です。

役割と機能の追加から「.NET Framework 3.5」を実施してみたところ、今度は成功した。

この状態で新しくインストールされる更新プログラムを確認したところ、.NET 3.5専用のものの他に、先ほど.NET 3.5用のみアンインストールしたKB5030184もインストールされること、ということが確認出来た。

で、実際に適用したあとに、履歴一覧を確認するとKB5030184 が2回適用されていることが確認できた。

Windows Updateしたらsamba ADへの接続がおかしくなった

sambaで作ったsamba AD環境がある。

最近、新しい仮想マシン作ってドメイン参加したあと、PowerShellで「Test-ComputerSecureChannel」を実行したら「False」と出た。

repairしても状況が変わらない

(ADサーバと該当マシン間の通信がセキュアチャネルを使って行われていないという状態)

いまつかっているsambaバージョンを確認すると4.18.2

# /usr/local/samba/sbin/smbd --version
Version 4.18.2
#

sambaのリリース履歴を見るとNetAppでも問題になったセキュリティ修正関連での修正が出ている。

CVE-2023-34967CVE-2022-2127CVE-2023-34968CVE-2023-34966 and CVE-2023-3347.

直接のバグとしては「Bug 15418 – secure channel faulty since Windows 10/11 update 07/2023」が該当している模様

バグであるならアップデートするしかないな、というわけで、samba 4.18.5へアップデート

展開して、make;make install; systemctl restart samba-ad-dc っと

# /usr/local/samba/sbin/smbd --version
Version 4.18.5
#

で、repairすると、今度は成功しました

Oracle Linux 9でWordPressサーバを立てる

Oracle Linux 9でwordpressサーバをたてる、という記事を2022年9月に書き始めたのですが、Oracle Linux 9用のEPELレポジトリにfail2banが含まれていなかっため、sshへの簡単な対策が行えないため書くのを中断していました。

2023年7月25日の更新でfail2banが収録されたようなので、改めて手順を作成してみます

記事修正履歴

2024/05/07: 4月下旬から常時稼働させてみての修正を追加開始
 手順2-4 kdump無効化 を追加
 手順14-1 php-fpm起動数制限 を追加
 手順14-2 swapfile追加

2025/08/14: wordpressが PHP 8.3を推奨したので修正
 手順 5 php追加で PHP 8.3を選択するよう修正
 このほか、Oracle Linux 9.2→9.6への修正
 準備 1-3: クラウドネットワークのセキュリティリストにhttp,https用設定を追加

準備1: Oracle Cloud用手順

準備1-1: IPv6アドレス割り当て:Oracle Cloudコンソール側

Oracle Cloudのコンソールを開いて、インスタンスにIPv6アドレスを割り当てます。

また、割り当てられたIPv6アドレスを確認します。

準備1-2: インスタンス側操作

Oracle Linux 9のイメージではIPv6が有効化されていたので、特に設定する必要はありませんでした。

準備 1-3: クラウドネットワークのセキュリティリストにhttp,https用設定

Oracle Cloudの[ネットワーキング]-[仮想クラウドネットワーク]にて、作成されているvcnを選択

[セキュリティ]をクリックし、「セキュリティリスト」を開き、登録されている「Default Security List for vcn~」をクリック

[セキュリティルール]タブにて、「イングレスルール」として以下を追加する

ソースタイプ: CIDR
ソースCIDR: 0.0.0.0/0
IPプロトコル: TCP
ソースポート範囲: all
宛先ポート範囲: 80,443
説明: http

準備2: 一般的な前準備

準備2-1: 日本時間にする

日本に住んでいる場合、日本時間表記の方が使いやすいので、OSも日本時間表示に設定する。

$ sudo timedatectl set-timezone Japan
$ 

準備2-2: パッケージを最新にアップデートする

現時点でインストール済みパッケージを最新にします。

Oracle Linux 9ではyum updateではなくdnf updateとなります。アップデート後は再起動します。(yumコマンドでも動きます)

$ sudo dnf update -y
<略>
$ sudo reboot

手順2-3:日本語Locale対応

ja_JP.UTF-8など日本語Localeで設定した際、「Failed to set locale, defaulting to C.UTF-8」というメッセージが出力される場合があります。

その場合は日本語Localeを追加インストールします。

$ sudo dnf install langpacks-ja glibc-langpack-ja
<略>
$

手順2-4:kdump無効化

(2024/05/07追加:OOK Killerが発動される率が高いので、少しでも影響を減らすために設定)

メモリが1GBしかないので、kdump.serviceの実行に失敗したりしている。

$ systemctl status kdump |cat
× kdump.service - Crash recovery kernel arming
     Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-05-07 09:22:57 JST; 5min ago
    Process: 2435 ExecStart=/usr/bin/kdumpctl start (code=exited, status=1/FAILURE)
   Main PID: 2435 (code=exited, status=1/FAILURE)
        CPU: 114ms
$

ダンプとっても使わないし、エラーとならないようkdumpを無効化してしまいます。

$ sudo systemctl disable kdump.service
Removed "/etc/systemd/system/multi-user.target.wants/kdump.service".
$

手順3: EPELレポジトリの追加

EPELレポジトリを使うので、使用できるようにします。

Oracle Linux 8と異なり、Oracle-Linux-9.2-2023.08.31-0 ではOracle CloudのOS管理下にレポジトリ管理が委託されていませんでした。

手順3-1:レポジトリの状態を確認

現状のレポジトリ設定状況を「sudo dnf repolist –all」を実行して確認します。

出力内に「This system is receiving updates from OSMS server.」という文字がなければこの手順で実行できます。

$ sudo dnf repolist --all
repo id                                 repo name                                                                  status
ol9_MODRHCK                             Latest RHCK with fixes from Oracle for Oracle Linux 9 (x86_64)             disabled
ol9_RDMA                                Oracle Linux 9 (x86_64) RDMA                                               disabled
ol9_UEKR7                               Oracle Linux 9 UEK Release 7 (x86_64)                                      disabled
ol9_UEKR8                               Oracle Linux 9 UEK Release 8 (x86_64)                                      enabled
ol9_addons                              Oracle Linux 9 Addons (x86_64)                                             enabled
ol9_appstream                           Oracle Linux 9 Application Stream Packages (x86_64)                        enabled
ol9_baseos_latest                       Oracle Linux 9 BaseOS Latest (x86_64)                                      enabled
ol9_codeready_builder                   Oracle Linux 9 CodeReady Builder (x86_64) - (Unsupported)                  disabled
ol9_developer                           Oracle Linux 9 Development Packages (x86_64)                               disabled
ol9_developer_EPEL                      Oracle Linux 9 EPEL Packages for Development (x86_64)                      disabled
ol9_developer_UEKR7                     Developer Preview of UEK Release 7 (x86_64)                                disabled
ol9_developer_kvm_utils                 Oracle Linux 9 KVM Utilities for Development and test (x86_64)             disabled
ol9_distro_builder                      Oracle Linux 9 Distro Builder (x86_64) - (Unsupported)                     disabled
ol9_ksplice                             Ksplice for Oracle Linux 9 (x86_64)                                        enabled
ol9_kvm_utils                           Oracle Linux 9 KVM Utilities (x86_64)                                      disabled
ol9_oci_included                        Oracle Linux 9 OCI Included Packages (x86_64)                              enabled
ol9_u0_baseos_base                      Oracle Linux 9 BaseOS GA (x86_64)                                          disabled
ol9_u1_baseos_base                      Oracle Linux 9.1 BaseOS (x86_64)                                           disabled
ol9_u2_baseos_base                      Oracle Linux 9.2 BaseOS (x86_64)                                           disabled
ol9_u3_baseos_base                      Oracle Linux 9.3 BaseOS (x86_64)                                           disabled
ol9_u3_security_validation              Oracle Linux 9 Update 3 (x86_64) Security Validations                      disabled
ol9_u4_baseos_base                      Oracle Linux 9.4 BaseOS (x86_64)                                           disabled
ol9_u5_baseos_base                      Oracle Linux 9.5 BaseOS (x86_64)                                           disabled
ol9_u6_baseos_base                      Oracle Linux 9.6 BaseOS (x86_64)                                           disabled
ol9_x86_64_userspace_ksplice            Ksplice aware userspace packages for Oracle Linux 9 (x86_64)               disabled
$

有効化するために「sudo dnf config-manager –set-enabled ol9_developer_EPEL」を実行します。

$ sudo dnf config-manager --set-enabled ol9_developer_EPEL
$ sudo dnf repolist --all
repo id                                 repo name                                                                  status
ol9_MODRHCK                             Latest RHCK with fixes from Oracle for Oracle Linux 9 (x86_64)             disabled
ol9_RDMA                                Oracle Linux 9 (x86_64) RDMA                                               disabled
ol9_UEKR7                               Oracle Linux 9 UEK Release 7 (x86_64)                                      disabled
ol9_UEKR8                               Oracle Linux 9 UEK Release 8 (x86_64)                                      enabled
ol9_addons                              Oracle Linux 9 Addons (x86_64)                                             enabled
ol9_appstream                           Oracle Linux 9 Application Stream Packages (x86_64)                        enabled
ol9_baseos_latest                       Oracle Linux 9 BaseOS Latest (x86_64)                                      enabled
ol9_codeready_builder                   Oracle Linux 9 CodeReady Builder (x86_64) - (Unsupported)                  disabled
ol9_developer                           Oracle Linux 9 Development Packages (x86_64)                               disabled
ol9_developer_EPEL                      Oracle Linux 9 EPEL Packages for Development (x86_64)                      enabled
ol9_developer_UEKR7                     Developer Preview of UEK Release 7 (x86_64)                                disabled
ol9_developer_kvm_utils                 Oracle Linux 9 KVM Utilities for Development and test (x86_64)             disabled
ol9_distro_builder                      Oracle Linux 9 Distro Builder (x86_64) - (Unsupported)                     disabled
ol9_ksplice                             Ksplice for Oracle Linux 9 (x86_64)                                        enabled
ol9_kvm_utils                           Oracle Linux 9 KVM Utilities (x86_64)                                      disabled
ol9_oci_included                        Oracle Linux 9 OCI Included Packages (x86_64)                              enabled
ol9_u0_baseos_base                      Oracle Linux 9 BaseOS GA (x86_64)                                          disabled
ol9_u1_baseos_base                      Oracle Linux 9.1 BaseOS (x86_64)                                           disabled
ol9_u2_baseos_base                      Oracle Linux 9.2 BaseOS (x86_64)                                           disabled
ol9_u3_baseos_base                      Oracle Linux 9.3 BaseOS (x86_64)                                           disabled
ol9_u3_security_validation              Oracle Linux 9 Update 3 (x86_64) Security Validations                      disabled
ol9_u4_baseos_base                      Oracle Linux 9.4 BaseOS (x86_64)                                           disabled
ol9_u5_baseos_base                      Oracle Linux 9.5 BaseOS (x86_64)                                           disabled
ol9_u6_baseos_base                      Oracle Linux 9.6 BaseOS (x86_64)                                           disabled
ol9_x86_64_userspace_ksplice            Ksplice aware userspace packages for Oracle Linux 9 (x86_64)               disabled
$

手順4: インターネット公開用設定

手順4-1: fail2ban導入

公開サーバは各種のアタックにさらされます。管理用sshポートにもやってきます。

多少なりとも軽減するためにEPELレポジトリ収録のfail2banを使用します。

$ sudo dnf install fail2ban -y
<略>
$

カスタム設定は/etc/fail2ban/jail.local に対して行います。

$ sudo vi /etc/fail2ban/jail.local
$ cat /etc/fail2ban/jail.local
[DEFAULT]
# 86400秒=24時間以内に5回不審なアクセスがあったら24時間BAN
bantime  = 86400
findtime  = 86400
maxretry = 5
# 259200秒=3日以内に5回不審なアクセスがあったら3日間BAN
#bantime  = 259200
#findtime  = 259200
#maxretry = 5
# 除外IP
ignoreip = 127.0.0.1 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
[sshd]
enabled = true
banaction = firewallcmd-ipset
$

上記設定では24時間BANにしていますが、まぁ、3日BANでもかまわないとは思います。(本当に間違えた場合に困るのでほどほどにしておくとよい)

fail2banをOS起動時に実行する設定と、今すぐfail2banを起動するコマンドを実行します。

$ sudo systemctl enable --now fail2ban
$

以降、アタックがあると /var/log/fail2ban.log にログが出ます。

手順4-2: Webサーバ用ポート公開設定

この段階では、dhcpv6-clientとsshのみが許可されています。

Webサーバ公開用にhttp(ポート80)とhttps(ポート443)を追加します。

$ sudo firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens3
  sources:
  services: dhcpv6-client ssh
  ports:
  protocols:
  forward: yes
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
$
$ sudo firewall-cmd --permanent --add-service=http
success
$ sudo firewall-cmd --permanent --add-service=https
success
$ sudo firewall-cmd --reload
success
$ sudo firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens3
  sources:
  services: dhcpv6-client http https ssh
  ports:
  protocols:
  forward: yes
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
$

手順5: php 追加

Oracle Linux 9環境では、moduleという形で複数バージョンのソフトウェアが提供されている場合があります。

phpに関してどのようなものがあるのかを「dnf module list php」を実行して確認します。

$ dnf module list php
Ksplice for Oracle Linux 9 (x86_64)                                                         74 MB/s | 7.7 MB     00:00
Oracle Linux 9 OCI Included Packages (x86_64)                                               64 MB/s | 178 MB     00:02
Oracle Linux 9 EPEL Packages for Development (x86_64)                                      110 MB/s |  30 MB     00:00
Oracle Linux 9 BaseOS Latest (x86_64)                                                      109 MB/s |  78 MB     00:00
Oracle Linux 9 Application Stream Packages (x86_64)                                        106 MB/s |  66 MB     00:00
Oracle Linux 9 Addons (x86_64)                                                              16 MB/s | 731 kB     00:00
Oracle Linux 9 UEK Release 8 (x86_64)                                                       83 MB/s | 9.4 MB     00:00
Last metadata expiration check: 0:00:01 ago on Thu 14 Aug 2025 02:01:31 PM JST.
Oracle Linux 9 Application Stream Packages (x86_64)
Name                 Stream                 Profiles                                  Summary
php                  8.1                    common [d], devel, minimal                PHP scripting language
php                  8.2                    common [d], devel, minimal                PHP scripting language
php                  8.3                    common [d], devel, minimal                PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
$

wordpressがphp 8.3を推奨しているので、「dnf install @php:8.3」とバージョン8.3を選択してインストールします

$ sudo dnf install @php:8.3 -y
Last metadata expiration check: 0:03:50 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                   Architecture    Version                                            Repository              Size
===========================================================================================================================
Installing group/module packages:
 php-cli                   x86_64          8.3.19-1.module+el9.6.0+90584+da8065b7             ol9_appstream          3.7 M
 php-common                x86_64          8.3.19-1.module+el9.6.0+90584+da8065b7             ol9_appstream          756 k
 php-fpm                   x86_64          8.3.19-1.module+el9.6.0+90584+da8065b7             ol9_appstream          1.9 M
 php-mbstring              x86_64          8.3.19-1.module+el9.6.0+90584+da8065b7             ol9_appstream          524 k
 php-xml                   x86_64          8.3.19-1.module+el9.6.0+90584+da8065b7             ol9_appstream          163 k
Installing dependencies:
 httpd-filesystem          noarch          2.4.62-4.0.1.el9                                   ol9_appstream           11 k
 libxslt                   x86_64          1.1.34-13.0.1.el9_6                                ol9_appstream          250 k
 nginx-filesystem          noarch          2:1.20.1-22.0.1.el9_6.3                            ol9_appstream          9.6 k
Installing module profiles:
 php/common
Enabling module streams:
 php                                       8.3

Transaction Summary
===========================================================================================================================
Install  8 Packages

Total download size: 7.3 M
Installed size: 36 M
Downloading Packages:
<略>
Installed:
  httpd-filesystem-2.4.62-4.0.1.el9.noarch                       libxslt-1.1.34-13.0.1.el9_6.x86_64
  nginx-filesystem-2:1.20.1-22.0.1.el9_6.3.noarch                php-cli-8.3.19-1.module+el9.6.0+90584+da8065b7.x86_64
  php-common-8.3.19-1.module+el9.6.0+90584+da8065b7.x86_64       php-fpm-8.3.19-1.module+el9.6.0+90584+da8065b7.x86_64
  php-mbstring-8.3.19-1.module+el9.6.0+90584+da8065b7.x86_64     php-xml-8.3.19-1.module+el9.6.0+90584+da8065b7.x86_64

Complete!
$

手順6: MySQL設定編

Oralce Linux 9.6ではMySQL 8.0.41 か mariadb 10.5.27が提供されています。

とりあえず、Oracle直営なのでMySQLを使っておきます。

$ sudo dnf install mysql-server -y
Last metadata expiration check: 0:05:55 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                                 Architecture        Version                      Repository                  Size
===========================================================================================================================
Installing:
 mysql-server                            x86_64              8.0.41-2.el9_5               ol9_appstream               17 M
Installing dependencies:
 mariadb-connector-c-config              noarch              3.2.6-1.el9_0                ol9_appstream              9.7 k
 mecab                                   x86_64              0.996-3.el9.4                ol9_appstream              384 k
 mysql                                   x86_64              8.0.41-2.el9_5               ol9_appstream              2.9 M
 mysql-common                            x86_64              8.0.41-2.el9_5               ol9_appstream              101 k
 mysql-errmsg                            x86_64              8.0.41-2.el9_5               ol9_appstream              526 k
 mysql-selinux                           noarch              1.0.13-1.el9_5               ol9_appstream               36 k
 protobuf-lite                           x86_64              3.14.0-16.el9                ol9_appstream              231 k

Transaction Summary
===========================================================================================================================
Install  8 Packages

Total download size: 21 M
Installed size: 180 M
<略>
Installed:
  mariadb-connector-c-config-3.2.6-1.el9_0.noarch  mecab-0.996-3.el9.4.x86_64          mysql-8.0.41-2.el9_5.x86_64
  mysql-common-8.0.41-2.el9_5.x86_64               mysql-errmsg-8.0.41-2.el9_5.x86_64  mysql-selinux-1.0.13-1.el9_5.noarch
  mysql-server-8.0.41-2.el9_5.x86_64               protobuf-lite-3.14.0-16.el9.x86_64

Complete!

mysqldを自動起動する設定といますぐ起動する設定をします。

$ sudo systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
$

WordPress用データベースを作成します。

MySQL 8におけるデータベースユーザ作成と権限の割り当てが従来の「grant all on DB名.* to wordpress@localhost identified by ‘パスワード’;」という一文から、「create user ~」と「grant ~」の2つに分かれている点に注意が必要です。

$ sudo mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.41 Source distribution

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database DB名 character set utf8;
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> create user wordpress@localhost  identified by 'パスワード';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on DB名.* to wordpress@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
$

手順7: Webサーバ設定

手順7-1: httpdインストール

httpdをインストールします。

Oracle Linux 9.6ではWebサーバとして Apache(httpd) 2.4.62 、nginx 1.20.1、nginx 1.26.3が使えるが、apacheを使う。

$ sudo dnf install httpd -y
Last metadata expiration check: 0:09:15 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                         Architecture        Version                          Repository                      Size
===========================================================================================================================
Installing:
 httpd                           x86_64              2.4.62-4.0.1.el9                 ol9_appstream                   64 k
Installing dependencies:
 apr                             x86_64              1.7.0-12.el9_3                   ol9_appstream                  131 k
 apr-util                        x86_64              1.6.1-23.el9                     ol9_appstream                   99 k
 apr-util-bdb                    x86_64              1.6.1-23.el9                     ol9_appstream                   12 k
 httpd-core                      x86_64              2.4.62-4.0.1.el9                 ol9_appstream                  1.8 M
 httpd-tools                     x86_64              2.4.62-4.0.1.el9                 ol9_appstream                   93 k
 oracle-logos-httpd              noarch              90.4-1.0.1.el9                   ol9_baseos_latest               37 k
Installing weak dependencies:
 apr-util-openssl                x86_64              1.6.1-23.el9                     ol9_appstream                   14 k
 mod_http2                       x86_64              2.0.26-4.el9                     ol9_appstream                  171 k
 mod_lua                         x86_64              2.4.62-4.0.1.el9                 ol9_appstream                   58 k

Transaction Summary
===========================================================================================================================
Install  10 Packages

Total download size: 2.4 M
Installed size: 6.1 M
<略>
Installed:
  apr-1.7.0-12.el9_3.x86_64                     apr-util-1.6.1-23.el9.x86_64       apr-util-bdb-1.6.1-23.el9.x86_64
  apr-util-openssl-1.6.1-23.el9.x86_64          httpd-2.4.62-4.0.1.el9.x86_64      httpd-core-2.4.62-4.0.1.el9.x86_64
  httpd-tools-2.4.62-4.0.1.el9.x86_64           mod_http2-2.0.26-4.el9.x86_64      mod_lua-2.4.62-4.0.1.el9.x86_64
  oracle-logos-httpd-90.4-1.0.1.el9.noarch

Complete!
$

次で設定変更をするので、この段階ではhttpdを起動しません。

OS起動時に自動起動する設定だけを行います。

$ sudo systemctl enable httpd
$

手順7-2: dehydratedによるLet’s Encrypt導入

Let’s EncryptによるSSL証明書導入はcertbotを使うのが一般的ではあるのだが、python環境とあわせてパッケージサイズが大きいので、コンパクトでEPELにも収録されているdehydratedを使用する。

$ sudo dnf install dehydrated -y
Last metadata expiration check: 0:11:13 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                    Architecture           Version                        Repository                          Size
===========================================================================================================================
Installing:
 dehydrated                 noarch                 0.7.1-6.el9                    ol9_developer_EPEL                 154 k
Installing dependencies:
 s-nail                     x86_64                 14.9.22-6.el9                  ol9_appstream                      626 k

Transaction Summary
===========================================================================================================================
Install  2 Packages
<略>
Installed:
  dehydrated-0.7.1-6.el9.noarch                                 s-nail-14.9.22-6.el9.x86_64

Complete!
$

dehydratedによるSSL証明書取得処理には /var/www/dehydrated が使用されるためディレクトリを作成します。

$ sudo mkdir /var/www/dehydrated
$

http://~/.well-known/acme-challenge でアクセスした時に上記ディレクトリが開くようApacheの設定を /etc/httpd/conf.d/dehydrated.conf として作成します。(sudo vi /etc/httpd/conf.d/dehydrated.conf )

$ sudo vi /etc/httpd/conf.d/dehydrated.conf
$ cat /etc/httpd/conf.d/dehydrated.conf
Alias /.well-known/acme-challenge /var/www/dehydrated
<Directory /var/www/dehydrated/>
</Directory>
$

httpdを起動します

$ sudo systemctl start httpd
$

SSL証明書を発行するホスト名を /etc/dehydrated/domains.txt に記載する。(sudo vi /etc/dehydrated/domains.txt)

1行に複数のホスト名を記載するとaliasになります。

$ sudo vi /etc/dehydrated/domains.txt
$ sudo cat /etc/dehydrated/domains.txt
ホスト1名.ドメイン名 ホスト2名.ドメイン名
$

登録操作を開始します。

$ sudo dehydrated --register
# INFO: Using main config file /etc/dehydrated/config
# INFO: Using additional config file /etc/dehydrated/conf.d/local.sh
To use dehydrated with this certificate authority you have to agree to their terms of service which you can find here: https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf
To accept these terms of service run "/bin/dehydrated --register --accept-terms".
$ sudo /bin/dehydrated --register --accept-terms
# INFO: Using main config file /etc/dehydrated/config
# INFO: Using additional config file /etc/dehydrated/conf.d/local.sh
+ Generating account key...
+ Registering account key with ACME server...
+ Fetching account URL...
+ Done!
$

初回のSSL証明書発行処理を実行します。

$ sudo dehydrated --cron
# INFO: Using main config file /etc/dehydrated/config
# INFO: Using additional config file /etc/dehydrated/conf.d/local.sh
 + Creating chain cache directory /etc/dehydrated/chains
Processing ホスト1名.ドメイン名 with alternative names: ホスト2名.ドメイン名
 + Creating new directory /etc/dehydrated/certs/ホスト1名.ドメイン名 ...
 + Signing domains...
 + Generating private key...
 + Generating signing request...
 + Requesting new certificate order from CA...
 + Received 2 authorizations URLs from the CA
 + Handling authorization for ホスト1名.ドメイン名
 + Handling authorization for ホスト2名.ドメイン名
 + 2 pending challenge(s)
 + Deploying challenge tokens...
 + Responding to challenge for ホスト1名.ドメイン名 authorization...
 + Challenge is valid!
 + Responding to challenge for ホスト2名.ドメイン名 authorization...
 + Challenge is valid!
 + Cleaning challenge tokens...
 + Requesting certificate...
 + Checking certificate...
 + Done!
 + Creating fullchain.pem...
 + Done!
 + Running automatic cleanup
$

手順7-3: WebサーバへのSSL証明書設定

まず、httpdにmod_sslを追加します。

$ sudo dnf install mod_ssl -y
Last metadata expiration check: 0:19:40 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                  Architecture            Version                             Repository                      Size
===========================================================================================================================
Installing:
 mod_ssl                  x86_64                  1:2.4.62-4.0.1.el9                  ol9_appstream                  117 k

Transaction Summary
===========================================================================================================================
Install  1 Package
<略>
$

標準の /etc/httpd/conf.d/ssl.conf は使わず、Mozilla SSL Configuration Generatorベースの設定を /etc/httpd/conf.d/ssl-mozilla.conf として作成します。(なお、ssl.conf には”Listen 443 https”設定もあるので、そのままにしています)

$ sudo vi /etc/httpd/conf.d/ssl-mozilla.conf
$ cat /etc/httpd/conf.d/ssl-mozilla.conf
# generated 2025-08-14, Mozilla Guideline v5.7, Apache 2.4.62, OpenSSL 3.2.2, intermediate config
# https://ssl-config.mozilla.org/#server=apache&version=2.4.62&config=intermediate&openssl=3.2.2&guideline=5.7

# this configuration requires mod_ssl, mod_rewrite, mod_headers, and mod_socache_shmcb
<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
    RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]
</VirtualHost>

<VirtualHost *:443>
    SSLEngine on

    # curl https://ssl-config.mozilla.org/ffdhe2048.txt >> /path/to/signed_cert_and_intermediate_certs_and_dhparams
    SSLCertificateFile      /etc/dehydrated/certs/<ホスト名>/cert.pem
    SSLCertificateKeyFile   /etc/dehydrated/certs/<ホスト名>/privkey.pem

    # enable HTTP/2, if available
    Protocols h2 http/1.1

    # HTTP Strict Transport Security (mod_headers is required) (63072000 seconds)
    Header always set Strict-Transport-Security "max-age=63072000"
</VirtualHost>

# intermediate configuration
SSLProtocol             -all +TLSv1.2 +TLSv1.3
SSLOpenSSLConfCmd       Curves X25519:prime256v1:secp384r1
SSLCipherSuite          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305
SSLHonorCipherOrder     off
SSLSessionTickets       off

SSLUseStapling On
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"
$

httpdを再起動します。

$ sudo systemctl restart httpd
$

手順8: WordPress導入

手順8-1: WordPressの基本インストール

WordPressのWebから最新版をダウンロードして、/var/www/html以下に展開します。
(日本語環境向けのlatest-ja.tar.gzファイルを使っていないのはWordpressプラグインが正常にインストールできるかを確認するためにWP Multibyte Patchを手動インストールする手順を入れているためです)

$ cd /var/www/html
$ ls
$ sudo curl -O https://wordpress.org/latest.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.3M  100 22.3M    0     0  17.6M      0  0:00:01  0:00:01 --:--:-- 17.6M
$ ls
latest.tar.gz
$ sudo tar xfz latest.tar.gz
$ ls -l
total 22904
-rw-r--r--. 1 root   root   23447259 Sep 12 11:57 latest.tar.gz
drwxr-xr-x. 5 nobody nobody     4096 Aug 29 23:14 wordpress
$ sudo rm latest.tar.gz
$

WordPressディレクトリの所有者をWebサービスのユーザである「apache」に変更します。

$ ps -ef|grep http
root       44914       1  0 11:56 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     44915   44914  0 11:56 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     44916   44914  0 11:56 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     44917   44914  0 11:56 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     44918   44914  0 11:56 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
opc        45353    7003  0 11:59 pts/0    00:00:00 grep --color=auto http
$ sudo chown -R apache:apache wordpress/
$ ls -l
total 4
drwxr-xr-x. 5 apache apache 4096 Aug 29 23:14 wordpress
$

/var/www/html/wordpress をDocumentRootとするように ssl-mozilla.conf に追加して、httpdを再起動します。

$ sudo vi /etc/httpd/conf.d/ssl-mozilla.conf
$ cat /etc/httpd/conf.d/ssl-mozilla.conf
# generated 2025-08-14, Mozilla Guideline v5.7, Apache 2.4.62, OpenSSL 3.2.2, intermediate config
# https://ssl-config.mozilla.org/#server=apache&version=2.4.62&config=intermediate&openssl=3.2.2&guideline=5.7

# this configuration requires mod_ssl, mod_rewrite, mod_headers, and mod_socache_shmcb
<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
    RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html/wordpress
    SSLEngine on

    # curl https://ssl-config.mozilla.org/ffdhe2048.txt >> /path/to/signed_cert_and_intermediate_certs_and_dhparams
    SSLCertificateFile      /etc/dehydrated/certs/<ホスト名>/cert.pem
    SSLCertificateKeyFile   /etc/dehydrated/certs/<ホスト名>/privkey.pem

    # enable HTTP/2, if available
    Protocols h2 http/1.1

    # HTTP Strict Transport Security (mod_headers is required) (63072000 seconds)
    Header always set Strict-Transport-Security "max-age=63072000"
</VirtualHost>

# intermediate configuration
SSLProtocol             -all +TLSv1.2 +TLSv1.3
SSLOpenSSLConfCmd       Curves X25519:prime256v1:secp384r1
SSLCipherSuite          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305
SSLHonorCipherOrder     off
SSLSessionTickets       off

SSLUseStapling On
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"
$ sudo systemctl restart httpd
$

手順8-2: 「missing the MySQL extension」がでる場合の手順

いまの状態でブラウザからアクセスすると、下記の表示になります。

これはphpからMySQLにアクセスするためのパッケージがインストールされていないためなので、php-mysqlndを追加して、httpdを再起動します。

$ sudo dnf install php-mysqlnd -y
Last metadata expiration check: 0:27:31 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                Architecture      Version                                           Repository                Size
===========================================================================================================================
Installing:
 php-mysqlnd            x86_64            8.3.19-1.module+el9.6.0+90584+da8065b7            ol9_appstream            150 k
Installing dependencies:
 php-pdo                x86_64            8.3.19-1.module+el9.6.0+90584+da8065b7            ol9_appstream             93 k

Transaction Summary
===========================================================================================================================
Install  2 Packages
<略>
$ sudo systemctl restart httpd
$

WordPressの設定手順を進めると wp-config.php に書き込めない、と出ますので、「sudo vi /var/www/html/wordpress/wp-config.php」を実行し、指定された内容を記載します。

よくヤル凡ミスとして、wordpress DBのユーザ名を指定するところで「ユーザ名@localhost」としてしまう、ということ。「ユーザ名」だけじゃないと接続できません

なお、wordpressの表示言語を日本語にすることは手順9-3で、パーマリンクのURL型式を変更する、というのは手順12の .htaccess に関する設定を入れてからにします。

手順9: SELinux設定

手順9-1: httpdのネットワーク接続問題

一見するとここまででうまく動いているように見えます。

しかし、プラグインをインストールしようとするとエラーになります。

/var/log/audit/audit.logを確認すると下記のようなログが出ています。

type=AVC msg=audit(1622095859.957:2064): avc:  denied  { name_connect } for  pid=8908 comm="php-fpm" dest=443 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=AVC msg=audit(1622095868.397:2065): avc:  denied  { name_connect } for  pid=8313 comm="php-fpm" dest=443 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0
type=AVC msg=audit(1622095868.401:2066): avc:  denied  { name_connect } for  pid=8313 comm="php-fpm" dest=80 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket permissive=0

これはhttpd_can_network_connect という値で制御されている

現在の設定値を「sudo getsebool -a |grep httpd_can_network」で確認し、「sudo setsebool -P httpd_can_network_connect on」で有効にする

$ sudo getsebool -a |grep httpd_can_network
httpd_can_network_connect --> off
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> off
httpd_can_network_memcache --> off
httpd_can_network_relay --> off
$ sudo setsebool -P httpd_can_network_connect on
$ sudo getsebool -a |grep httpd_can_network
httpd_can_network_connect --> on
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> off
httpd_can_network_memcache --> off
httpd_can_network_relay --> off
$

この変更ではhttpdの再起動は不要。

手順9-2: php-fpmの書き込み権限問題

プラグインやテーマのインストールについては問題なくても、WordPressのアップデートが出来ない。

このときの/var/log/audit/audit.logは下記

type=AVC msg=audit(1694506911.363:1538): avc:  denied  { write } for  pid=51364 comm="php-fpm" name="wordpress" dev="dm-0" ino=34891933 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:httpd_sys_content_t:s0 tclass=dir permissive=0

こちらは/var/www/html/wordpress に対して httpdから書き込みが行えるような SELinuxのコンテキストをつけることで解決する。

「sudo chcon -R -t httpd_sys_script_rw_t /var/www/html/wordpress」

$ ls -lZ /var/www/html/
total 4
drwxr-xr-x. 5 apache apache unconfined_u:object_r:httpd_sys_content_t:s0 4096 Sep 12 13:14 wordpress
$ sudo chcon -R -t httpd_sys_script_rw_t /var/www/html/wordpress
$ ls -lZ /var/www/html/
total 4
drwxr-xr-x. 5 apache apache unconfined_u:object_r:httpd_sys_rw_content_t:s0 4096 Sep 12 13:14 wordpress
$

手順9-3:Wordpressプラグイン追加の動作確認

WordPressプラグインがインストールできる状態になっているかを確認するために「WP Multibyte Patch」をインストールします。

これをインストールするとWordpressの設定画面([Settings]-[General])に「Site language(サイトの言語)」が追加され、「日本語」表示に切り替えることができるようになります。

手順10: WordPressで取り扱えるファイルサイズの拡大

WordPressで取り扱えるファイルは標準状態だと2MBになっている。

WordPressのドキュメントのFile Upload Sizes を見ると、これはphpの設定ファイル /etc/php.ini による制限となっている。

Oracle Linux 9の標準設定では下記の値となっている。

<略>
post_max_size = 8M
<略>
upload_max_filesize = 2M
<略>

で・・・よくある手順だと軽率に /etc/php.ini を書き換えていますが、 /etc/php.d/ 以下にファイルを追加することで、そちらの設定項目を優先させることができる機能があるため、 /etc/php.d/90-wordpress.ini に変更したい2行だけを記載したファイルを作成します。

$ sudo vi /etc/php.d/90-wordpress.ini
$ cat /etc/php.d/90-wordpress.ini
post_max_size = 100M
upload_max_filesize = 100M
$

phpの設定変更を反映させるために「sudo systemctl restart php-fpm」を実行します。

$ sudo systemctl restart php-fpm
$

手順11: WordPressのSite Health Status対応

WordPressのサイトステータスを見てみると、いくつかパッケージを要求されている。

上から順に調査

Oracle Linux 8ではimagemagickのphpモジュールはなかったが、Oracle Linux 9だとあったので「sudo dnf install php-pecl-imagick」でインストールしたいのだが、Oracle Linux 9.6 + php 8.3環境だと、php 8.3向けモジュールが出ていないため失敗する

$ sudo dnf install php-pecl-imagick
Last metadata expiration check: 0:45:12 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Error:
 Problem: package php-pecl-imagick-3.7.0-1.el9.x86_64 from ol9_developer_EPEL requires php(api) = 20200930-64, but none of the providers can be installed
  - package php-pecl-imagick-3.7.0-1.el9.x86_64 from ol9_developer_EPEL requires php(zend-abi) = 20200930-64, but none of the providers can be installed
  - conflicting requests
  - package php-common-8.0.13-1.el9.x86_64 from ol9_appstream is filtered out by modular filtering
  - package php-common-8.0.13-2.el9_0.x86_64 from ol9_appstream is filtered out by modular filtering
  - package php-common-8.0.20-3.el9.x86_64 from ol9_appstream is filtered out by modular filtering
  - package php-common-8.0.27-1.el9_1.x86_64 from ol9_appstream is filtered out by modular filtering
  - package php-common-8.0.30-1.el9_2.x86_64 from ol9_appstream is filtered out by modular filtering
  - package php-common-8.0.30-2.el9.x86_64 from ol9_appstream is filtered out by modular filtering
  - package php-common-8.0.30-3.el9_6.x86_64 from ol9_appstream is filtered out by modular filtering
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
$

仕方が無いので、gd周りだけで我慢することにして「sudo dnf install gd php-gd」を実行する

$ sudo dnf install php-gd
Last metadata expiration check: 0:47:35 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                Architecture     Version                                             Repository               Size
===========================================================================================================================
Installing:
 php-gd                 x86_64           8.3.19-1.module+el9.6.0+90584+da8065b7              ol9_appstream            40 k
Installing dependencies:
 gd                     x86_64           2.3.2-3.el9                                         ol9_appstream           132 k
 jbigkit-libs           x86_64           2.1-23.el9                                          ol9_appstream            58 k
 libXpm                 x86_64           3.5.13-10.el9                                       ol9_appstream            62 k
 libtiff                x86_64           4.4.0-13.el9                                        ol9_appstream           204 k
 libwebp                x86_64           1.2.0-8.el9_3                                       ol9_appstream           286 k

Transaction Summary
===========================================================================================================================
Install  6 Packages

Total download size: 782 k
Installed size: 2.1 M
Is this ok [y/N]: y
<略>
Installed:
  gd-2.3.2-3.el9.x86_64          jbigkit-libs-2.1-23.el9.x86_64    libXpm-3.5.13-10.el9.x86_64
  libtiff-4.4.0-13.el9.x86_64    libwebp-1.2.0-8.el9_3.x86_64      php-gd-8.3.19-1.module+el9.6.0+90584+da8065b7.x86_64

Complete!
$

インストール後にサイトヘルスステータスを確認するとgdが消えている

続いて「sudo dnf install php-pecl-zip php-intl」をインストール

$ sudo dnf install php-pecl-zip php-intl
Last metadata expiration check: 0:49:22 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                Architecture     Version                                             Repository               Size
===========================================================================================================================
Installing:
 php-intl               x86_64           8.3.19-1.module+el9.6.0+90584+da8065b7              ol9_appstream           168 k
 php-pecl-zip           x86_64           1.22.3-1.module+el9.6.0+90525+5083e899              ol9_appstream            81 k
Installing dependencies:
 libzip                 x86_64           1.7.3-8.el9                                         ol9_appstream            61 k

Transaction Summary
===========================================================================================================================
Install  3 Packages

Total download size: 310 k
Installed size: 883 k
Is this ok [y/N]: y
<略>
Installed:
  libzip-1.7.3-8.el9.x86_64                                      php-intl-8.3.19-1.module+el9.6.0+90584+da8065b7.x86_64
  php-pecl-zip-1.22.3-1.module+el9.6.0+90525+5083e899.x86_64

Complete!
$

これで、サイトヘルスステータスのパッケージ関連でimagick以外のメッセージは消えた。

手順12: WordPressの.htaccess有効化

/var/www/html/wordpress/.htaccess が作成されているが、Oracle Linux 8のhttpd標準設定ではこれを読み込むようにはなっていない。

これが有効になっていないと、パーマリンク設定を「基本」から変えた場合に個別記事にアクセスできなくなる。

/etc/httpd/conf.d/wordpress.conf にファイルを作って設定する。

$ sudo vi /etc/httpd/conf.d/wordpress.conf
$ cat /etc/httpd/conf.d/wordpress.conf
<Directory /var/www/html/wordpress/>
 Allowoverride All
</Directory>
$ sudo systemctl restart httpd
$

手順13: OS自動更新の設定

メンテナンスがめんどくさくなって忘れる可能性があるので、Oracle Linux 8の自動更新設定を実施。

以前はyum-cronでしたが、現在は dnf-automatic に変わったので、パッケージをインストールします。

$ sudo dnf install dnf-automatic -y
Last metadata expiration check: 0:50:58 ago on Thu 14 Aug 2025 01:58:49 PM JST.
Dependencies resolved.
===========================================================================================================================
 Package                     Architecture         Version                            Repository                       Size
===========================================================================================================================
Installing:
 dnf-automatic               noarch               4.14.0-25.0.1.el9                  ol9_baseos_latest                52 k

Transaction Summary
===========================================================================================================================
Install  1 Package
<略>
$

/etc/dnf/automatic.conf 内の「apply_updates = no」を「apply_updates = yes」に変更

$ sudo vi /etc/dnf/automatic.conf
$ cat /etc/dnf/automatic.conf
[commands]
#  What kind of upgrade to perform:
# default                            = all available upgrades
# security                           = only the security upgrades
upgrade_type = default
random_sleep = 0
# Maximum time in seconds to wait until the system is on-line and able to
# connect to remote repositories.
network_online_timeout = 60
# To just receive updates use dnf-automatic-notifyonly.timer
# Whether updates should be downloaded when they are available, by
# dnf-automatic.timer. notifyonly.timer, download.timer and
# install.timer override this setting.
download_updates = yes
# Whether updates should be applied when they are available, by
# dnf-automatic.timer. notifyonly.timer, download.timer and
# install.timer override this setting.
apply_updates = yes
[emitters]
# Name to use for this system in messages that are emitted.  Default is the
# hostname.
# system_name = my-host
# How to send messages.  Valid options are stdio, email and motd.  If
# emit_via includes stdio, messages will be sent to stdout; this is useful
# to have cron send the messages.  If emit_via includes email, this
# program will send email itself according to the configured options.
# If emit_via includes motd, /etc/motd file will have the messages. if
# emit_via includes command_email, then messages will be send via a shell
# command compatible with sendmail.
# Default is email,stdio.
# If emit_via is None or left blank, no messages will be sent.
emit_via = stdio
[email]
# The address to send email messages from.
email_from = root@example.com
# List of addresses to send messages to.
email_to = root
# Name of the host to connect to to send email messages.
email_host = localhost
[command]
# The shell command to execute. This is a Python format string, as used in
# str.format(). The format function will pass a shell-quoted argument called
# `body`.
# command_format = "cat"
# The contents of stdin to pass to the command. It is a format string with the
# same arguments as `command_format`.
# stdin_format = "{body}"
[command_email]
# The shell command to use to send email. This is a Python format string,
# as used in str.format(). The format function will pass shell-quoted arguments
# called body, subject, email_from, email_to.
# command_format = "mail -Ssendwait -s {subject} -r {email_from} {email_to}"
# The contents of stdin to pass to the command. It is a format string with the
# same arguments as `command_format`.
# stdin_format = "{body}"
# The address to send email messages from.
email_from = root@example.com
# List of addresses to send messages to.
email_to = root
[base]
# This section overrides dnf.conf
# Use this to filter DNF core messages
debuglevel = 1
$

そしてdnf-automatic.timerを有効化し、開始します。

$ sudo systemctl enable dnf-automatic.timer
Created symlink /etc/systemd/system/timers.target.wants/dnf-automatic.timer → /usr/lib/systemd/system/dnf-automatic.timer.
$ sudo systemctl status dnf-automatic
○ dnf-automatic.service - dnf automatic
     Loaded: loaded (/usr/lib/systemd/system/dnf-automatic.service; static)
     Active: inactive (dead)
TriggeredBy: ○ dnf-automatic.timer
$ sudo systemctl start dnf-automatic.timer
$ sudo systemctl status dnf-automatic.timer
● dnf-automatic.timer - dnf-automatic timer
     Loaded: loaded (/usr/lib/systemd/system/dnf-automatic.timer; enabled; pres>
     Active: active (waiting) since Tue 2023-09-12 13:11:00 JST; 5s ago
      Until: Tue 2023-09-12 13:11:00 JST; 5s ago
    Trigger: Wed 2023-09-13 06:44:33 JST; 17h left
   Triggers: ● dnf-automatic.service
Sep 12 13:11:00 ホスト名 systemd[1]: Started dnf-automatic timer.
$

手順14 メモリが足らない対策

Oracle CloudのFree Tierで初期値のまま稼働させてみたのですが、頻繁に応答がなくなりました。(Oracle Linux 8だと問題なかったんだけど、Oracle Linux 9だと1日複数回発生)

oom-killerが発動したり、dnf search実行したら応答が返ってこない、とか・・・(dnf searchの件はどうやらdnfレポジトリの環境問題のもよう・・・)

手順14-1 php-fpm起動数制限

メモリ消費が増えやすいものとしてphp-fpmがある

zabbix向けでの記事ではあるが「php-fpmのメモリ使用量が増加する問題について」なんてのがあるぐらいにはよくあることになっている。

/etc/php-fpm.d/www.conf にある設定ファイルで設定されているので、まずは現在値を確認

動的に子プロセスを生成 (pm = dynamic)
プロセス最大数が50 (pm.max_children = 50)
開始プロセス数は5 (pm.start_servers = 5)
スペアサーバの最低は5(pm.min_spare_servers = 5)
スペアサーバの最大は35(pm.max_spare_servers = 35)
プロセスの自動再起動は設定なし(”;pm.max_requests = 500″なのでコメントになっている)

これを下記に変更し、「systemctl restart php-fpm」で再起動した。

動的に子プロセスを生成 (pm = dynamic)
プロセス最大数が8 (pm.max_children = 8)
開始プロセス数は5 (pm.start_servers = 5)
スペアサーバの最低は5(pm.min_spare_servers = 5)
スペアサーバの最大は8(pm.max_spare_servers = 8)
プロセスの自動再起動は500(pm.max_requests = 500)

これでしばらく様子をみてみることにした(2024/05/07設定)

手順14-2 swapfile追加

yum/dnfレポジトリのファイルサイズが80MB程度を越えるとdnfコマンドの処理中にswapが1GBちょっと必要になるようだ。

標準だと1GBなく、ほかのプロセスで400MB程度は使用されているので、足らないため、swapを増量する必要がある模様。

現在の設定確認するため「swapon –show」を実行して、容量と、swapfileの権限等を確認

# swapon --show
NAME       TYPE SIZE   USED PRIO
/.swapfile file 948M 488.4M   -2
# ls -l /.swapfile
-rw-------. 1 root root 994050048  4月 25 10:59 /.swapfile
#

「/パーテーション」か「/var/oledパーテーション」のどちらかに追加のswapfileを作成

# fallocate -l 2G /var/oled/swapfile2
# ls -l /var/oled/swapfile2
-rw-r--r--. 1 root root 2147483648  5月  7 14:06 /var/oled/swapfile2
# chmod 600 /var/oled/swapfile2
# ls -l /var/oled/swapfile2
-rw-------. 1 root root 2147483648  5月  7 14:06 /var/oled/swapfile2
# mkswap /var/oled/swapfile2
スワップ空間バージョン 1 を設定します。サイズ = 2 GiB (2147479552 バイト)
ラベルはありません, UUID=66caa2dd-b28d-43da-b1a6-8b710f8a8398
# 

作成したファイルをswapとして登録

# swapon /var/oled/swapfile2
# swapon --show
NAME                TYPE SIZE   USED PRIO
/.swapfile          file 948M 487.4M   -2
/var/oled/swapfile2 file   2G     0B   -3
# 

free -mを実行してswapが増えていることを確認

# free -m
               total        used        free      shared  buff/cache   available
Mem:             948         512          65          26         545         436
Swap:           2995         487        2508
#

また、上記は再起動すると消えるので/etc/fstabに「/var/oled/swapfile2 none swap sw 0 0」を追加


トラブルメモ

ここからは一般的ではないトラブルの対処メモ

dnfコマンド実行したあとに応答がなくなる

OCI Free Tier(メモリ1GB)のインスタンスでOracle Linux 9をインストールしたあと、dnf check-updateを実行すると、systemのloadが非常に上がったあと、応答がなくなるということとが多発した。

EPEL追加したあとから動きがおかしくなってる?という感じがあったので、いったん全部のレポジトリを無効化してからOS系を有効にしたところ、dnfが止まらずに実行完了した。

# dnf repolist
repo id                       repo の名前
ol9_addons                    Oracle Linux 9 Addons (x86_64)
ol9_appstream                 Oracle Linux 9 Application Stream Packages (x86_64)
ol9_baseos_latest             Oracle Linux 9 BaseOS Latest (x86_64)
# 

この状態で「dnf update」を実行したところ、EPELで追加したパッケージと関連する部分があって一括アップデートができなかった。

アップデートにdnf周りとセキュリティ周りをアップデートすればいいか、と以下のパッケージについて個別アップデートを実施した

dnf update yum selinux-policy policycoreutils rpm dnf-plugins-core

UEKを戻して以下の状態でもdnf check-updateは成功

# dnf repolist
repo id                       repo の名前
ol9_UEKR7                     Oracle Linux 9 UEK Release 7 (x86_64)
ol9_addons                    Oracle Linux 9 Addons (x86_64)
ol9_appstream                 Oracle Linux 9 Application Stream Packages (x86_64)
ol9_baseos_latest             Oracle Linux 9 BaseOS Latest (x86_64)
#

しかし、”Oracle Linux 9 OCI Included Packages (x86_64)”(oci-included-ol9.repo)を戻したところ応答がなくなる現象発生

# dnf repolist
repo id                       repo の名前
ol9_UEKR7                     Oracle Linux 9 UEK Release 7 (x86_64)
ol9_addons                    Oracle Linux 9 Addons (x86_64)
ol9_appstream                 Oracle Linux 9 Application Stream Packages (x86_64)
ol9_baseos_latest             Oracle Linux 9 BaseOS Latest (x86_64)
ol9_oci_included              Oracle Linux 9 OCI Included Packages (x86_64)
# dnf check-update
Oracle Linux 9 OCI Included Packages (x86_64)                  27 MB/s |  84 MB     00:03
<ここから出力が続かない>

強制再起動したあと、Oracle Linux 9 OCI Included Packages (x86_64)を除外して、EPELを含めてそれ以外の状態を戻してみるとdnf check-updateに成功

# dnf repolist
repo id                                repo の名前
ol9_UEKR7                              Oracle Linux 9 UEK Release 7 (x86_64)
ol9_addons                             Oracle Linux 9 Addons (x86_64)
ol9_appstream                          Oracle Linux 9 Application Stream Packages (x86_64)
ol9_baseos_latest                      Oracle Linux 9 BaseOS Latest (x86_64)
ol9_developer_EPEL                     Oracle Linux 9 EPEL Packages for Development (x86_64)
ol9_ksplice                            Ksplice for Oracle Linux 9 (x86_64)
#

が・・・dnf updateでエラーが・・・

# dnf update -y
メタデータの期限切れの最終確認: 0:01:49 前の 2024年05月07日 11時32分27秒 に実施しました。
エラー:
 問題 1: package ImageMagick-libs-6.9.12.93-1.el9.x86_64 from @System requires libraw_r.so.20()(64bit), but none of the providers can be installed
  - cannot install both LibRaw-0.21.1-1.el9.x86_64 from ol9_appstream and LibRaw-0.20.2-6.el9.x86_64 from @System
  - cannot install both LibRaw-0.21.1-1.el9.x86_64 from ol9_appstream and LibRaw-0.20.2-5.el9.x86_64 from ol9_appstream
  - cannot install both LibRaw-0.21.1-1.el9.x86_64 from ol9_appstream and LibRaw-0.20.2-6.el9.x86_64 from ol9_appstream
  - パッケージの最良アップデート候補をインストールできません LibRaw-0.20.2-6.el9.x86_64
  - パッケージの最良アップデート候補をインストールできません ImageMagick-libs-6.9.12.93-1.el9.x86_64
 問題 2: package tuned-profiles-oci-2.21.0-1.0.1.el9_3.noarch from @System requires tuned = 2.21.0-1.0.1.el9_3, but none of the providers can be installed
  - cannot install both tuned-2.22.1-1.0.1.el9.noarch from ol9_baseos_latest and tuned-2.21.0-1.0.1.el9_3.noarch from @System
  - cannot install both tuned-2.22.1-1.0.1.el9.noarch from ol9_baseos_latest and tuned-2.21.0-1.0.1.el9_3.noarch from ol9_baseos_latest
  - パッケージの最良アップデート候補をインストールできません tuned-2.21.0-1.0.1.el9_3.noarch
  - インストール済パッケージの問題 tuned-profiles-oci-2.21.0-1.0.1.el9_3.noarch
(競合するパッケージを置き換えるには、コマンドラインに '--allowerasing' を追加してみてください または、'--skip-broken' を追加して、インストール不可のパッケージをスキップしてください または、'--nobest' を追加して、最適候補のパッケージのみを使用しないでください)
#

現在無効にしているociレポジトリにあるtuned-profiles-ociを引っ張ってきてるから駄目な模様

$ cat /etc/yum.repos.d/oci-included-ol9.repo
[ol9_oci_included]
name=Oracle Linux $releasever OCI Included Packages ($basearch)
baseurl=https://yum$ociregion.$ocidomain/repo/OracleLinux/OL9/oci/included/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
$

ここの環境変数 $ociregionと$ocidomainはどこで定義されているかといえば、/etc/yum/vars/ociregion と /etc/yum/vars/ocidomain

$ ls -l  /etc/yum/vars/
合計 12
-rw-r--r--. 1 root root 20  4月 25 10:59 ocidomain
-rw-r--r--. 1 root root 14  4月 25 10:59 ociregion
-rw-r--r--. 1 root root 13  4月 25 10:59 region
$ cat /etc/yum/vars/ocidomain
oci.oraclecloud.com
$ cat /etc/yum/vars/ociregion
.us-phoenix-1
$ cat /etc/yum/vars/region
us-phoenix-1
$

とりあえずはoracle linuxのreleaseが新しくなっていたので個別アップデート

# dnf update oraclelinux-release oraclelinux-release-el9 redhat-release
メタデータの期限切れの最終確認: 0:17:52 前の 2024年05月07日 11時32分27秒 に実施しました。
依存関係が解決しました。
=================================================================================================================
 パッケージ                       Arch            バージョン                    リポジトリー               サイズ
=================================================================================================================
アップグレード:
 oraclelinux-release              x86_64          9:9.4-1.0.6.el9               ol9_baseos_latest          8.3 M
 oraclelinux-release-el9          x86_64          1.0-15.el9                    ol9_baseos_latest           23 k
 redhat-release                   x86_64          3:9.4-0.4.0.1.el9             ol9_baseos_latest           19 k

トランザクションの概要
=================================================================================================================
アップグレード  3 パッケージ

ダウンロードサイズの合計: 8.3 M
これでよろしいですか? [y/N]: y
<略>
#

OCIに関するレポジトリ設定は変更されなかったので、パッケージ除外設定でdnf updateを実施した( 「dnf update -y –exclude=tuned*,ImageMagick-libs,LibRaw」で実行した)

# dnf update -y --exclude=tuned*
メタデータの期限切れの最終確認: 0:21:39 前の 2024年05月07日 11時32分27秒 に実施しました。
エラー:
 問題: package ImageMagick-libs-6.9.12.93-1.el9.x86_64 from @System requires libraw_r.so.20()(64bit), but none of the providers can be installed
  - cannot install both LibRaw-0.21.1-1.el9.x86_64 from ol9_appstream and LibRaw-0.20.2-6.el9.x86_64 from @System
  - cannot install both LibRaw-0.21.1-1.el9.x86_64 from ol9_appstream and LibRaw-0.20.2-5.el9.x86_64 from ol9_appstream
  - cannot install both LibRaw-0.21.1-1.el9.x86_64 from ol9_appstream and LibRaw-0.20.2-6.el9.x86_64 from ol9_appstream
  - パッケージの最良アップデート候補をインストールできません LibRaw-0.20.2-6.el9.x86_64
  - パッケージの最良アップデート候補をインストールできません ImageMagick-libs-6.9.12.93-1.el9.x86_64
(競合するパッケージを置き換えるには、コマンドラインに '--allowerasing' を追加してみてください または、'--skip-broken' を追加して、インストール不可のパッケージをスキップしてください または、'--nobest' を追加して、最適候補のパッケージのみを使用しないでください)
# dnf update -y --exclude=tuned*,ImageMagick-libs,LibRaw
メタデータの期限切れの最終確認: 0:22:54 前の 2024年05月07日 11時32分27秒 に実施しました。
依存関係が解決しました。
<略>

アップデート完了後、Oracle Linux 9 OCI Included Packages (x86_64)を戻してdnf check-updateを実行すると、これまでと同じで止まる

該当レポジトリからインストールされているものを確認する

# dnf list --installed|grep ol9_oci_included
ksplice-release-el9.x86_64                     1.0-2.el9                           @ol9_oci_included
oci-linux-config.noarch                        2.0-1.0.8.el9                       @ol9_oci_included
oci-utils.noarch                               0.14.0-4.el9                        @ol9_oci_included
python3-cryptography.x86_64                    36.0.1-4.0.1.el9                    @ol9_oci_included
python3-docutils.noarch                        0.16-6.el9                          @ol9_oci_included
python3-sdnotify.noarch                        0.3.2-4.el9                         @ol9_oci_included
python39-oci-sdk.x86_64                        2.125.3-1.el9                       @ol9_oci_included
tuned-profiles-oci.noarch                      2.21.0-1.0.1.el9_3                  @ol9_oci_included
tuned-profiles-oci-recommend.noarch            2.21.0-1.0.1.el9_3                  @ol9_oci_included
#

twitterで検索したら、同じような事例で止まったという話をしてる人を発見

どう対処したのか聞いてみたところswap増量したとのこと。

# swapon --show
NAME       TYPE SIZE   USED PRIO
/.swapfile file 948M 488.4M   -2
# ls -l /.swapfile
-rw-------. 1 root root 994050048  4月 25 10:59 /.swapfile
#

/etc/fstabには「/.swapfile none swap sw,comment=cloudconfig 0 0」という行あり

# fallocate -l 2G /var/oled/swapfile2
# ls -l /var/oled/swapfile2
-rw-r--r--. 1 root root 2147483648  5月  7 14:06 /var/oled/swapfile2
# chmod 600 /var/oled/swapfile2
# ls -l /var/oled/swapfile2
-rw-------. 1 root root 2147483648  5月  7 14:06 /var/oled/swapfile2
# mkswap /var/oled/swapfile2
スワップ空間バージョン 1 を設定します。サイズ = 2 GiB (2147479552 バイト)
ラベルはありません, UUID=66caa2dd-b28d-43da-b1a6-8b710f8a8398
# swapon /var/oled/swapfile2
# swapon --show
NAME                TYPE SIZE   USED PRIO
/.swapfile          file 948M 487.4M   -2
/var/oled/swapfile2 file   2G     0B   -3
# free -m
               total        used        free      shared  buff/cache   available
Mem:             948         512          65          26         545         436
Swap:           2995         487        2508
#

そして dnf check-updateを実行

# dnf check-update
メタデータの期限切れの最終確認: 1:08:36 前の 2024年05月07日 13時04分17秒 に実施しました。

LibRaw.x86_64                                             0.21.1-1.el9                            ol9_appstream
python39-oci-sdk.x86_64                                   2.126.1-1.el9                           ol9_oci_included
tuned.noarch                                              2.22.1-1.0.1.el9                        ol9_baseos_latest
tuned-profiles-oci.noarch                                 2.22.1-1.0.1.el9                        ol9_oci_included
tuned-profiles-oci-recommend.noarch                       2.22.1-1.0.1.el9                        ol9_oci_included
#
# dnf check-update
Ksplice for Oracle Linux 9 (x86_64)                                                413 kB/s | 380 kB     00:00
Oracle Linux 9 OCI Included Packages (x86_64)                                       29 MB/s |  84 MB     00:02
Oracle Linux 9 EPEL Packages for Development (x86_64)                               17 MB/s |  59 MB     00:03
Oracle Linux 9 BaseOS Latest (x86_64)                                               14 MB/s |  24 MB     00:01
Oracle Linux 9 Application Stream Packages (x86_64)                                 18 MB/s |  33 MB     00:01
Oracle Linux 9 Addons (x86_64)                                                     516 kB/s | 396 kB     00:00
Oracle Linux 9 UEK Release 7 (x86_64)                                               15 MB/s |  31 MB     00:02
メタデータの期限切れの最終確認: 0:00:01 前の 2024年05月07日 14時32分44秒 に実施しました。

LibRaw.x86_64                                      0.21.1-1.el9                                       ol9_appstream
#

問題なく通りました。

実行中 topコマンドでメモリ消費を見てみたところ、swapを最大で1600MBぐらいまで使用していた。dnfコマンドの実行が終わると640MB程度の使用になったので、約1GBぐらいが必要である模様

ふとOracle Linux 8 ARMインスタンスでswapを確認してみると4GBで設定されていた。それが1GBに減ってるのでは確かに足らないですね・・・

$ swapon --show
NAME       TYPE SIZE   USED PRIO
/.swapfile file   4G 556.1M   -2
$ ls -l /.swapfile
-rw-------. 1 root root 4294967296 Apr  6  2022 /.swapfile
$ free -m
              total        used        free      shared  buff/cache   available
Mem:           5759        2216        2708          23         833        2696
Swap:          4095         556        3539
$

Oracle Linux 8 x86_64 インスタンスだと1.9GBで、以前は問題なかったんだけど、いま試すとdnfがOOM killerで殺されるようになっていた・・・(合計3.9GBに増やしたあとで確認すると最大で2376MBまで使用されていた)

$ swapon --show
NAME       TYPE SIZE  USED PRIO
/.swapfile file 1.9G 84.1M   -2
$ ls -l /.swapfile
-rw-------. 1 root root 1989148672 Mar  8  2023 /.swapfile
$ free -m
              total        used        free      shared  buff/cache   available
Mem:            936         541          63           1         331         246
Swap:          1896         467        1429
$ 

ただ作成時期によってはOracle linux 8 x86_64インスタンスでも8GBで設定されているようだ

$ swapon --show
NAME       TYPE SIZE  USED PRIO
/.swapfile file   8G 66.3M   -2
$ ls -l /.swapfile
-rw-------. 1 root root 8589934592 Nov 16  2021 /.swapfile
$ free -m
              total        used        free      shared  buff/cache   available
Mem:          23236        5527        3452         740       14257       13471
Swap:          8191          66        8125
$

Oracle Linux 7 x86_64インスタンスだとswap 8GB

$ swapon --show
NAME      TYPE      SIZE   USED PRIO
/dev/sda2 partition   8G 489.5M   -2
$

OCI関連コマンドドキュメント

OCIユーティリティ

OCIリージョン内のyumサーバに関する記載 リージョナルYumサーバーへの接続

Oracle Cloud Agentドキュメント


Windows11インストール時に時刻と通貨の形式設定をいじっておくと余計なアプリがインストールされない件

twitterで「Windows 11を「英語(世界)」でインストールすると余計なアプリがインストールされないんだぜ(意訳)」というのが回ってきたので検証してみた。

とりあえずvSphere環境でインストールを実施

時刻と通過の形式を「英語(世界)」に選択するけど、インストールする言語とキーボードまたは入力方式は「日本語」とする設定でWindows 11のインストールを実施

インストール完了して確認!

確かに余計なアプリがインストールされていません。

なぜかなぁ・・・と思いつつMicrosoft Storeを起動してみると原因判明

「英語(世界)」ではMicrosoft Storeが利用できないため、Microsoft Store経由でインストールされる余計なアプリのインストールができない、という状態でした。

設定を戻してみる

インストール時に変更した設定を戻した場合にどうなるかを確認するため、[時刻と言語]の[言語と地域]にある設定を変更

最初は「国または地域:すべて」「地域設定:英語(世界)」でした。

通常の日本語として設定する場合は「国または地域:日本」「地域設定:日本語(日本)」となります。

最初は地域設定のみを変えてみたのですが、その場合はタスクバーに表示される日付表示などは変更されましたが、Microsoft Storeの動作は変更されませんでした。

設定変更後、再起動することでMicrosoft Storeも使用できるようになりました。

今回インストールしたWindows 11 22H2だと約49個のアプリがMicrosoft Store経由のアップデート対象となっていたようです。

ストア系アプリのアップデートが全て完了した状態で確認してみます。

特にアプリは追加されていないようですね。

ということで、インストール時の変更で余計なアプリをインストールさせない、という手法でした。

ただ・・・たぶん、Microsoftアカウントと連携してしまうと、そちら経由でアプリが追加されたりするんじゃないかなぁ・・・とかは感じます