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

Oracle Cloud InfrastructureでOracle Linux 10イメージがリリースされました。

2025/09/09時点では Oracle-Linux-10.0-2025.08.31-0 というバージョンでした。

こちらを使用してWordPressサーバを立ててみる手順です

ただ、2025/09/09時点ではOracle Linux 10用のOracle Cloud Agentが完成していない、ということで、いまいちお勧めできない状況です。

記事修正履歴

2025/09/09: 作成
2025/09/10:
 手順14 SSL証明書自動更新設定を追加
 準備1-3: イングレスルールとエグレスルールにIPv6用設定を追加

2025/09/19: トラブル対応手順
 トラブル対応手順1: python3-pyOpenSSLのconflict問題

2026/04/30: 修正
 Oracle-Linux-10.1-2026.03.31-0 で実施した場合の情報を反映

準備1: Oracle Cloud用手順

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

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

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

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

Oracle Linux 10のイメージでは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

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

また、IPv6経由のsshでアクセスしたい場合にルールがない場合は下記も追加

ソースタイプ: CIDR
ソースCIDR: ::/0
IPプロトコル: TCP
ソースポート範囲: all
宛先ポート範囲: 22
説明: ssh for IPv6

[セキュリティルール]タブにて、「エグレスルール」として以下を追加する(IPv4用の登録はすでにあるが、IPv6用の登録がないので追加する)

宛先タイプ: CIDR
宛先CIDR: ::/0
IPプロトコル: すべてのポートのすべてのトラフィック
説明:

準備2: 一般的な前準備

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

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

$ sudo timedatectl set-timezone Japan
$ 

手順2-2:swap追加

Oracle Linux 8からメモリ1GB環境ではEPELレポジトリ追加後のdnfコマンド処理で応答がなくなることが多発している。

調査した結果、メモリとスワップが少ないと発生し、Oracle Linux 9環境では合計で5GB程度ないと支障がでる、ということがわかった。

2025/09/09時点での Oracle-Linux-10.0-2025.08.31-0 ではスワップは約1GBと足らない状態となっている。

追加のファイルスワップを作成できそうな領域は「/パーテーション」か「/var/oledパーテーション」となるので、どちらかにファイルスワップを作成する

[opc@oci10 ~]$ sudo fallocate -l 4G /var/oled/swapfile
[opc@oci10 ~]$ ls -l /var/oled/swapfile 
-rw-r--r--. 1 root root 4294967296 Sep  9 13:35 /var/oled/swapfile
[opc@oci10 ~]$ sudo chmod 600 /var/oled/swapfile 
[opc@oci10 ~]$ ls -l /var/oled/swapfile 
-rw-------. 1 root root 4294967296 Sep  9 13:35 /var/oled/swapfile
[opc@oci10 ~]$ sudo mkswap /var/oled/swapfile 
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
no label, UUID=bdd4f7a6-1dcc-43c8-bb2d-8f42ac2faf3f
[opc@oci10 ~]$ 

作成したファイルをスワップとして登録

[opc@oci10 ~]$ sudo swapon /var/oled/swapfile 
[opc@oci10 ~]$ swapon --show
NAME               TYPE SIZE   USED PRIO
/.swapfile         file 951M 144.4M   -2
/var/oled/swapfile file   4G     0B   -3
[opc@oci10 ~]$ cat /proc/swaps 
Filename                                Type            Size            Used            Priority
/.swapfile                              file            973820          147908          -2
/var/oled/swapfile                      file            4194300         0               -3
[opc@oci10 ~]$ 

/etc/fstabにスワップファイルの記述「/var/oled/swapfile none swap sw 0 0」を追加

[opc@oci10 ~]$ sudo vi /etc/fstab 
[opc@oci10 ~]$ cat /etc/fstab 
#
# /etc/fstab
# Created by anaconda on Wed Jul 16 02:09:25 2025
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=7d252e5c-0a4d-4f09-afca-58d232b956c2 /                       xfs     defaults        0 0
UUID=02208839-bc64-488a-9f5f-b87452a0f76d /boot                   xfs     defaults        0 0
UUID=9A6D-CFD1          /boot/efi               vfat    defaults,uid=0,gid=0,umask=077,shortname=winnt 0 2
UUID=81c1f07e-ee73-470f-b0ec-d21ad8693c3e /var/oled               xfs     defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults,nodev,nosuid,noexec      0 0
######################################
## ORACLE CLOUD INFRASTRUCTURE CUSTOMERS
##
## If you are adding an iSCSI remote block volume to this file you MUST
## include the '_netdev' mount option or your instance will become
## unavailable after the next reboot.
## SCSI device names are not stable across reboots; please use the device UUID instead of /dev path.
##
## Example:
## UUID="94c5aade-8bb1-4d55-ad0c-388bb8aa716a"   /data1    xfs       defaults,noatime,_netdev      0      2
##
## More information:
## https://docs.cloud.oracle.com/Content/Block/Tasks/connectingtoavolume.htm
/.swapfile      none    swap    sw      0       0
/var/oled/swapfile      none    swap    sw      0       0
[opc@oci10 ~]$ 

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

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

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

2025/09/19時点ではpython3-pyOpenSSL関連で失敗したので、その場合は、後述の「トラブル対応手順1: python3-pyOpenSSLのconflict問題」を行う (2026/04/30時点ではこの問題は発生しなくなった)

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

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

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

$ sudo dnf install langpacks-ja 
<略>
$

手順2-5:kdump無効化

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

[opc@oci10 ~]$ systemctl status kdump
× kdump.service - Crash recovery kernel arming
     Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2025-09-09 12:01:53 JST; 1h 24min ago
 Invocation: 1833096bfd314195995486c8d6963173
   Main PID: 2556 (code=exited, status=1/FAILURE)
   Mem peak: 3.3M
        CPU: 59ms

Sep 09 12:01:52 oci10 systemd[1]: Starting kdump.service - Crash recovery kernel arming...
Sep 09 12:01:53 oci10 kdumpctl[2586]: kdump: No memory reserved for crash kernel
Sep 09 12:01:53 oci10 kdumpctl[2586]: kdump: Starting kdump: [FAILED]
Sep 09 12:01:53 oci10 systemd[1]: kdump.service: Main process exited, code=exited, status=1/FAILURE
Sep 09 12:01:53 oci10 systemd[1]: kdump.service: Failed with result 'exit-code'.
Sep 09 12:01:53 oci10 systemd[1]: Failed to start kdump.service - Crash recovery kernel arming.
[opc@oci10 ~]$ 

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

[opc@oci10 ~]$ sudo systemctl disable kdump.service
Removed '/etc/systemd/system/multi-user.target.wants/kdump.service'.
[opc@oci10 ~]$ 

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

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

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

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

[opc@oci10 ~]$ sudo dnf repolist --all
repo id                                                                                                                                 repo name                                                                                                                                                                status
ol10_RDMA                                                                                                                               Oracle Linux 10 (x86_64) RDMA                                                                                                                                            disabled
ol10_UEKR8                                                                                                                              Oracle Linux 10 UEK Release 8 (x86_64)                                                                                                                                   enabled
ol10_addons                                                                                                                             Oracle Linux 10 Addons (x86_64)                                                                                                                                          enabled
ol10_appstream                                                                                                                          Oracle Linux 10 Application Stream Packages (x86_64)                                                                                                                     enabled
ol10_baseos_latest                                                                                                                      Oracle Linux 10 BaseOS Latest (x86_64)                                                                                                                                   enabled
ol10_codeready_builder                                                                                                                  Oracle Linux 10 CodeReady Builder (x86_64) - (Unsupported)                                                                                                               disabled
ol10_developer                                                                                                                          Oracle Linux 10 Development Packages (x86_64)                                                                                                                            disabled
ol10_distro_builder                                                                                                                     Oracle Linux 10 Distro Builder (x86_64) - (Unsupported)                                                                                                                  disabled
ol10_ksplice                                                                                                                            Ksplice for Oracle Linux 10 (x86_64)                                                                                                                                     enabled
ol10_oci_included                                                                                                                       Oracle Linux 10 OCI Included Packages (x86_64)                                                                                                                           enabled
ol10_u0_baseos_base                                                                                                                     Oracle Linux 10 BaseOS GA (x86_64)                                                                                                                                       disabled
ol10_u0_developer_EPEL                                                                                                                  Oracle Linux 10.0 EPEL Packages for Development (x86_64)                                                                                                                 disabled
ol10_x86_64_userspace_ksplice                                                                                                           Ksplice aware userspace packages for Oracle Linux 10 (x86_64)                                                                                                            disabled
[opc@oci10 ~]$ 

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

2026/04/30時点では「sudo dnf config-manager –set-enabled ol10_u1_developer_EPEL」です

[opc@oci10 ~]$ sudo dnf config-manager --set-enabled ol10_u0_developer_EPEL
[opc@oci10 ~]$ sudo dnf repolist --all
repo id                                                                                                                                 repo name                                                                                                                                                                status
ol10_RDMA                                                                                                                               Oracle Linux 10 (x86_64) RDMA                                                                                                                                            disabled
ol10_UEKR8                                                                                                                              Oracle Linux 10 UEK Release 8 (x86_64)                                                                                                                                   enabled
ol10_addons                                                                                                                             Oracle Linux 10 Addons (x86_64)                                                                                                                                          enabled
ol10_appstream                                                                                                                          Oracle Linux 10 Application Stream Packages (x86_64)                                                                                                                     enabled
ol10_baseos_latest                                                                                                                      Oracle Linux 10 BaseOS Latest (x86_64)                                                                                                                                   enabled
ol10_codeready_builder                                                                                                                  Oracle Linux 10 CodeReady Builder (x86_64) - (Unsupported)                                                                                                               disabled
ol10_developer                                                                                                                          Oracle Linux 10 Development Packages (x86_64)                                                                                                                            disabled
ol10_distro_builder                                                                                                                     Oracle Linux 10 Distro Builder (x86_64) - (Unsupported)                                                                                                                  disabled
ol10_ksplice                                                                                                                            Ksplice for Oracle Linux 10 (x86_64)                                                                                                                                     enabled
ol10_oci_included                                                                                                                       Oracle Linux 10 OCI Included Packages (x86_64)                                                                                                                           enabled
ol10_u0_baseos_base                                                                                                                     Oracle Linux 10 BaseOS GA (x86_64)                                                                                                                                       disabled
ol10_u0_developer_EPEL                                                                                                                  Oracle Linux 10.0 EPEL Packages for Development (x86_64)                                                                                                                 enabled
ol10_x86_64_userspace_ksplice                                                                                                           Ksplice aware userspace packages for Oracle Linux 10 (x86_64)                                                                                                            disabled
[opc@oci10 ~]$ 

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

手順4-1: fail2ban導入

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

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

$ sudo dnf install fail2ban -y
<略>
$

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

[opc@oci10 ~]$ sudo vi /etc/fail2ban/jail.local
[opc@oci10 ~]$ 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
[opc@oci10 ~]$ 

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

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

[opc@oci10 ~]$ sudo systemctl enable --now fail2ban
Created symlink '/etc/systemd/system/multi-user.target.wants/fail2ban.service' → '/usr/lib/systemd/system/fail2ban.service'.
[opc@oci10 ~]$ 

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

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

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

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

[opc@oci10 ~]$ sudo firewall-cmd --list-all
public (default, active)
  target: default
  ingress-priority: 0
  egress-priority: 0
  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: 
[opc@oci10 ~]$ 
[opc@oci10 ~]$ sudo firewall-cmd --permanent --add-service=http
success
[opc@oci10 ~]$ sudo firewall-cmd --permanent --add-service=https
success
[opc@oci10 ~]$ sudo firewall-cmd --reload
success
[opc@oci10 ~]$ sudo firewall-cmd --list-all
public (default, active)
  target: default
  ingress-priority: 0
  egress-priority: 0
  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: 
[opc@oci10 ~]$ 

手順5: php 追加

Oracle Linux 8と9であったmoduleで複数バージョン提供という機能はOracle Linux 10ではなくなりました。(Using DNF Modules and Application Streams)

No modular packages are available for Oracle Linux 10. Different versions of userspace packages continue to be available as Application Streams but don’t use the package modularity available in previous releases.

なので、単純に「dnf install php」でインストールします。

[opc@oci10 ~]$ sudo dnf install php -y
Last metadata expiration check: 0:13:46 ago on Tue 09 Sep 2025 01:42:02 PM JST.
Dependencies resolved.
=========================================================================================================================================================================================================================================================================================================================
 Package                                                                       Architecture                                                      Version                                                                             Repository                                                                     Size
=========================================================================================================================================================================================================================================================================================================================
Installing:
 php                                                                           x86_64                                                            8.3.19-1.el10_0                                                                     ol10_appstream                                                                 75 k
Installing dependencies:
 apr                                                                           x86_64                                                            1.7.5-2.el10                                                                        ol10_appstream                                                                135 k
 apr-util                                                                      x86_64                                                            1.6.3-21.el10                                                                       ol10_appstream                                                                102 k
 apr-util-lmdb                                                                 x86_64                                                            1.6.3-21.el10                                                                       ol10_appstream                                                                 14 k
 capstone                                                                      x86_64                                                            5.0.1-6.el10                                                                        ol10_appstream                                                                1.0 M
 httpd-core                                                                    x86_64                                                            2.4.63-1.0.1.el10_0.2                                                               ol10_appstream                                                                1.8 M
 httpd-filesystem                                                              noarch                                                            2.4.63-1.0.1.el10_0.2                                                               ol10_appstream                                                                9.1 k
 httpd-tools                                                                   x86_64                                                            2.4.63-1.0.1.el10_0.2                                                               ol10_appstream                                                                 91 k
 libxslt                                                                       x86_64                                                            1.1.39-8.el10_0                                                                     ol10_appstream                                                                208 k
 mailcap                                                                       noarch                                                            2.1.54-8.el10                                                                       ol10_baseos_latest                                                             39 k
 nginx-filesystem                                                              noarch                                                            2:1.26.3-1.0.1.el10                                                                 ol10_appstream                                                                 31 k
 oracle-logos-httpd                                                            noarch                                                            100.1-1.0.3.el10                                                                    ol10_baseos_latest                                                             53 k
 php-common                                                                    x86_64                                                            8.3.19-1.el10_0                                                                     ol10_appstream                                                                815 k
Installing weak dependencies:
 apr-util-openssl                                                              x86_64                                                            1.6.3-21.el10                                                                       ol10_appstream                                                                 16 k
 httpd                                                                         x86_64                                                            2.4.63-1.0.1.el10_0.2                                                               ol10_appstream                                                                 63 k
 mod_http2                                                                     x86_64                                                            2.0.29-2.el10_0.1                                                                   ol10_appstream                                                                177 k
 mod_lua                                                                       x86_64                                                            2.4.63-1.0.1.el10_0.2                                                               ol10_appstream                                                                 55 k
 php-cli                                                                       x86_64                                                            8.3.19-1.el10_0                                                                     ol10_appstream                                                                3.7 M
 php-fpm                                                                       x86_64                                                            8.3.19-1.el10_0                                                                     ol10_appstream                                                                1.9 M
 php-mbstring                                                                  x86_64                                                            8.3.19-1.el10_0                                                                     ol10_appstream                                                                584 k
 php-opcache                                                                   x86_64                                                            8.3.19-1.el10_0                                                                     ol10_appstream                                                                430 k
 php-pdo                                                                       x86_64                                                            8.3.19-1.el10_0                                                                     ol10_appstream                                                                158 k
 php-xml                                                                       x86_64                                                            8.3.19-1.el10_0                                                                     ol10_appstream                                                                225 k

Transaction Summary
=========================================================================================================================================================================================================================================================================================================================
Install  23 Packages

Total download size: 12 M
Installed size: 57 M
Downloading Packages:
<略>
  Running scriptlet: httpd-2.4.63-1.0.1.el10_0.2.x86_64                                                                                                                                                                                                                                                            23/23 
  Running scriptlet: php-8.3.19-1.el10_0.x86_64                                                                                                                                                                                                                                                                    23/23 

Installed:
  apr-1.7.5-2.el10.x86_64                            apr-util-1.6.3-21.el10.x86_64                 apr-util-lmdb-1.6.3-21.el10.x86_64      apr-util-openssl-1.6.3-21.el10.x86_64      capstone-5.0.1-6.el10.x86_64            httpd-2.4.63-1.0.1.el10_0.2.x86_64        httpd-core-2.4.63-1.0.1.el10_0.2.x86_64         
  httpd-filesystem-2.4.63-1.0.1.el10_0.2.noarch      httpd-tools-2.4.63-1.0.1.el10_0.2.x86_64      libxslt-1.1.39-8.el10_0.x86_64          mailcap-2.1.54-8.el10.noarch               mod_http2-2.0.29-2.el10_0.1.x86_64      mod_lua-2.4.63-1.0.1.el10_0.2.x86_64      nginx-filesystem-2:1.26.3-1.0.1.el10.noarch     
  oracle-logos-httpd-100.1-1.0.3.el10.noarch         php-8.3.19-1.el10_0.x86_64                    php-cli-8.3.19-1.el10_0.x86_64          php-common-8.3.19-1.el10_0.x86_64          php-fpm-8.3.19-1.el10_0.x86_64          php-mbstring-8.3.19-1.el10_0.x86_64       php-opcache-8.3.19-1.el10_0.x86_64              
  php-pdo-8.3.19-1.el10_0.x86_64                     php-xml-8.3.19-1.el10_0.x86_64               

Complete!
[opc@oci10 ~]$ 

php 8.3.19がインストールされました。

手順6: MySQL設定編

Oralce Linux 10ではMySQL 8.4.4 か mariadb 10.11.11が提供されています。

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

[opc@oci10 ~]$ sudo dnf install mysql8.4-server -y
Last metadata expiration check: 0:17:41 ago on Tue 09 Sep 2025 01:42:02 PM JST.
Dependencies resolved.
=========================================================================================================================================================================================================================================================================================================================
 Package                                                                               Architecture                                                      Version                                                                     Repository                                                                     Size
=========================================================================================================================================================================================================================================================================================================================
Installing:
 mysql8.4-server                                                                       x86_64                                                            8.4.4-2.el10                                                                ol10_appstream                                                                 18 M
Installing dependencies:
 libicu                                                                                x86_64                                                            74.2-5.el10_0                                                               ol10_baseos_latest                                                             10 M
 mariadb-connector-c-config                                                            noarch                                                            3.4.4-1.el10                                                                ol10_baseos_latest                                                            8.8 k
 mecab                                                                                 x86_64                                                            0.996-9.el10                                                                ol10_appstream                                                                390 k
 mysql-selinux                                                                         noarch                                                            1.0.13-2.el10                                                               ol10_appstream                                                                 37 k
 mysql8.4                                                                              x86_64                                                            8.4.4-2.el10                                                                ol10_appstream                                                                2.4 M
 mysql8.4-common                                                                       noarch                                                            8.4.4-2.el10                                                                ol10_appstream                                                                102 k
 mysql8.4-errmsg                                                                       noarch                                                            8.4.4-2.el10                                                                ol10_appstream                                                                545 k
 protobuf-lite                                                                         x86_64                                                            3.19.6-11.el10                                                              ol10_appstream                                                                262 k

Transaction Summary
=========================================================================================================================================================================================================================================================================================================================
Install  9 Packages

Total download size: 32 M
Installed size: 199 M
Downloading Packages:
<略>
  Running scriptlet: mysql8.4-server-8.4.4-2.el10.x86_64                                                                                                                                                                                                                                                             9/9 

Installed:
  libicu-74.2-5.el10_0.x86_64            mariadb-connector-c-config-3.4.4-1.el10.noarch    mecab-0.996-9.el10.x86_64    mysql-selinux-1.0.13-2.el10.noarch    mysql8.4-8.4.4-2.el10.x86_64    mysql8.4-common-8.4.4-2.el10.noarch    mysql8.4-errmsg-8.4.4-2.el10.noarch    mysql8.4-server-8.4.4-2.el10.x86_64   
  protobuf-lite-3.19.6-11.el10.x86_64   

Complete!
[opc@oci10 ~]$ 

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

[opc@oci10 ~]$ sudo systemctl enable --now mysqld
Created symlink '/etc/systemd/system/multi-user.target.wants/mysqld.service' → '/usr/lib/systemd/system/mysqld.service'.
[opc@oci10 ~]$ 

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

[opc@oci10 ~]$ sudo mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.4 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.02 sec)

mysql> grant all privileges on DB名.* to wordpress@localhost;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[opc@oci10 ~]$ 

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

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

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

[opc@oci10 ~]$ sudo dnf install httpd -y
Last metadata expiration check: 0:23:31 ago on Tue 09 Sep 2025 01:42:02 PM JST.
Package httpd-2.4.63-1.0.1.el10_0.2.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[opc@oci10 ~]$ 

よく見たらphpインストール時にインストールされていました。

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

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

[opc@oci10 ~]$ sudo dnf install dehydrated -y
Last metadata expiration check: 0:25:08 ago on Tue 09 Sep 2025 01:42:02 PM JST.
Dependencies resolved.
=========================================================================================================================================================================================================================================================================================================================
 Package                                                                  Architecture                                                         Version                                                                        Repository                                                                            Size
=========================================================================================================================================================================================================================================================================================================================
Installing:
 dehydrated                                                               noarch                                                               0.7.1-6.el10_0                                                                 ol10_u0_developer_EPEL                                                               156 k
Installing dependencies:
 s-nail                                                                   x86_64                                                               14.9.24-12.el10                                                                ol10_appstream                                                                       641 k

Transaction Summary
=========================================================================================================================================================================================================================================================================================================================
Install  2 Packages

Total download size: 797 k
Installed size: 1.4 M
Downloading Packages:
<略>
Installed:
  dehydrated-0.7.1-6.el10_0.noarch                                                                                                                             s-nail-14.9.24-12.el10.x86_64                                                                                                                            

Complete!
[opc@oci10 ~]$ 

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

[opc@oci10 ~]$ sudo mkdir /var/www/dehydrated
[opc@oci10 ~]$

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

[opc@oci10 ~]$ sudo vi /etc/httpd/conf.d/dehydrated.conf
[opc@oci10 ~]$ cat /etc/httpd/conf.d/dehydrated.conf 
Alias /.well-known/acme-challenge /var/www/dehydrated
<Directory /var/www/dehydrated/>
</Directory>
[opc@oci10 ~]$ 

httpdを起動します

[opc@oci10 ~]$ sudo systemctl start httpd
[opc@oci10 ~]$ 

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

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

登録操作を開始します。

[opc@oci10 ~]$ 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.5-February-24-2025.pdf

To accept these terms of service run "/bin/dehydrated --register --accept-terms".
[opc@oci10 ~]$ sudo 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!
[opc@oci10 ~]$ 

初回の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を追加します。

[opc@oci10 ~]$ sudo dnf install mod_ssl -y
Last metadata expiration check: 0:33:34 ago on Tue 09 Sep 2025 01:42:02 PM JST.
Dependencies resolved.
=========================================================================================================================================================================================================================================================================================================================
 Package                                                                Architecture                                                          Version                                                                                Repository                                                                     Size
=========================================================================================================================================================================================================================================================================================================================
Installing:
 mod_ssl                                                                x86_64                                                                1:2.4.63-1.0.1.el10_0.2                                                                ol10_appstream                                                                113 k
Installing dependencies:
 sscg                                                                   x86_64                                                                3.0.5-9.el10                                                                           ol10_appstream                                                                 50 k

Transaction Summary
=========================================================================================================================================================================================================================================================================================================================
Install  2 Packages

Total download size: 163 k
Installed size: 366 k
Downloading Packages:
<略>
Installed:
  mod_ssl-1:2.4.63-1.0.1.el10_0.2.x86_64                                                                                                                             sscg-3.0.5-9.el10.x86_64                                                                                                                            

Complete!
[opc@oci10 ~]$ 

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

また、Let’s encryptingを使用する場合2025年5月以降OCSPに対応しなくなりました(Removing OCSP URLs from Certificates)

このため、「SSLUseStapling Off」を設定します

# generated 2025-09-09, Mozilla Guideline v5.7, Apache 2.4.63, OpenSSL 3.2.2, intermediate config
# https://ssl-config.mozilla.org/#server=apache&amp;version=2.4.63&amp;config=intermediate&amp;openssl=3.2.2&amp;guideline=5.7

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

&lt;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/<ホスト名>/fullchain.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"
&lt;/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 Off
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"

httpdを再起動します。

[opc@oci10 ~]$ sudo systemctl restart httpd
[opc@oci10 ~]$ 

手順8: WordPress導入

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

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

[opc@oci10 ~]$ cd /var/www/html
[opc@oci10 html]$ ls
[opc@oci10 html]$ 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 25.6M  100 25.6M    0     0  4909k      0  0:00:05  0:00:05 --:--:-- 5921k
[opc@oci10 html]$ ls
latest.tar.gz
[opc@oci10 html]$ sudo tar xfz latest.tar.gz 
[opc@oci10 html]$ ls -l
total 26300
-rw-r--r--. 1 root root 26925441 Sep  9 14:33 latest.tar.gz
drwxr-xr-x. 5 root root     4096 Jul 16 00:09 wordpress
[opc@oci10 html]$ sudo rm latest.tar.gz 
[opc@oci10 html]$ ls
wordpress
[opc@oci10 html]$

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

[opc@oci10 html]$ ps -ef|grep http
root       66623       1  0 14:30 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     66624   66623  0 14:30 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     66625   66623  0 14:30 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     66639   66623  0 14:30 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     66644   66623  0 14:30 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     66808   66623  0 14:31 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
opc        66961    7040  0 14:34 pts/0    00:00:00 grep --color=auto http
[opc@oci10 html]$ sudo chown -R apache:apache wordpress/
[opc@oci10 html]$ ls -l
total 4
drwxr-xr-x. 5 apache apache 4096 Jul 16 00:09 wordpress
[opc@oci10 html]$ 

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

[opc@oci10 html]$ sudo vi /etc/httpd/conf.d/ssl-mozilla.conf 
[opc@oci10 html]$ cat /etc/httpd/conf.d/ssl-mozilla.conf 
# generated 2025-09-09, Mozilla Guideline v5.7, Apache 2.4.63, OpenSSL 3.2.2, intermediate config
# https://ssl-config.mozilla.org/#server=apache&version=2.4.63&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/<ホスト名>/fullchain.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 Off
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"
[opc@oci10 html]$ 
[opc@oci10 html]$ sudo systemctl restart httpd
[opc@oci10 html]$ 

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

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

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

[opc@oci10 ~]$ sudo dnf install php-mysqlnd -y
Last metadata expiration check: 0:55:51 ago on Tue 09 Sep 2025 01:42:02 PM JST.
Dependencies resolved.
=========================================================================================================================================================================================================================================================================================================================
 Package                                                                     Architecture                                                           Version                                                                         Repository                                                                      Size
=========================================================================================================================================================================================================================================================================================================================
Installing:
 php-mysqlnd                                                                 x86_64                                                                 8.3.19-1.el10_0                                                                 ol10_appstream                                                                 211 k

Transaction Summary
=========================================================================================================================================================================================================================================================================================================================
Install  1 Package

Total download size: 211 k
Installed size: 378 k
Downloading Packages:
<略>
Installed:
  php-mysqlnd-8.3.19-1.el10_0.x86_64                                                                                                                                                                                                                                                                                     

Complete!
[opc@oci10 ~]$ sudo systemctl restart httpd
[opc@oci10 ~]$ 

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」で有効にする

[opc@oci10 ~]$ sudo vi /var/www/html/wordpress/wp-config.php
[opc@oci10 ~]$ 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_redis --> off
httpd_can_network_relay --> off
[opc@oci10 ~]$ sudo setsebool -P httpd_can_network_connect on
[opc@oci10 ~]$ 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_redis --> off
httpd_can_network_relay --> off
[opc@oci10 ~]$ 

この変更では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」

[opc@oci10 ~]$ sudo ls -lZ /var/www/html/
total 4
drwxr-xr-x. 5 apache apache unconfined_u:object_r:httpd_sys_content_t:s0 4096 Sep  9 14:39 wordpress
[opc@oci10 ~]$ sudo chcon -R -t httpd_sys_script_rw_t /var/www/html/wordpress
[opc@oci10 ~]$ sudo 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  9 14:39 wordpress
[opc@oci10 ~]$ 

手順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 10の標準設定では下記の値となっている。

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

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

[opc@oci10 ~]$ sudo vi /etc/php.d/90-wordpress.ini
[opc@oci10 ~]$ cat /etc/php.d/90-wordpress.ini 
post_max_size = 100M
upload_max_filesize = 100M
[opc@oci10 ~]$ 

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

[opc@oci10 ~]$ sudo systemctl restart php-fpm
[opc@oci10 ~]$ 

手順11: WordPressのSite Health Status対応

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

Oracle Linux 10.0では php-pecl-imagick php-pecl-zip php-intl をインストールする

[opc@oci10 ~]$ sudo dnf install php-pecl-imagick php-pecl-zip php-intl -y
Last metadata expiration check: 1:10:03 ago on Tue 09 Sep 2025 01:42:02 PM JST.
Dependencies resolved.
=========================================================================================================================================================================================================================================================================================================================
 Package                                                                                    Architecture                                                 Version                                                                      Repository                                                                    Size
=========================================================================================================================================================================================================================================================================================================================
Installing:
 php-intl                                                                                   x86_64                                                       8.3.19-1.el10_0                                                              ol10_appstream                                                               228 k
 php-pecl-imagick                                                                           x86_64                                                       3.8.0-1.el10_0                                                               ol10_u0_developer_EPEL                                                       163 k
 php-pecl-zip                                                                               x86_64                                                       1.22.3-5.el10                                                                ol10_appstream                                                                82 k
Installing dependencies:
 ImageMagick-libs                                                                           x86_64                                                       1:7.1.1.43-1.el10_0                                                          ol10_u0_developer_EPEL                                                       2.7 M
 LibRaw                                                                                     x86_64                                                       0.21.3-1.el10_0                                                              ol10_u0_developer_EPEL                                                       430 k
 adobe-mappings-cmap                                                                        noarch                                                       20230622-5.el10                                                              ol10_appstream                                                               2.3 M
 adobe-mappings-cmap-deprecated                                                             noarch                                                       20230622-5.el10                                                              ol10_appstream                                                               128 k
 adobe-mappings-pdf                                                                         noarch                                                       20190401-9.el10                                                              ol10_appstream                                                               728 k
 cairo                                                                                      x86_64                                                       1.18.2-2.el10                                                                ol10_appstream                                                               725 k
 cairo-gobject                                                                              x86_64                                                       1.18.2-2.el10                                                                ol10_appstream                                                                17 k
 cups-filesystem                                                                            noarch                                                       1:2.4.10-11.el10                                                             ol10_baseos_latest                                                            13 k
 cups-libs                                                                                  x86_64                                                       1:2.4.10-11.el10                                                             ol10_baseos_latest                                                           266 k
 fftw-libs-double                                                                           x86_64                                                       3.3.10-15.el10                                                               ol10_appstream                                                               1.1 M
 fontconfig                                                                                 x86_64                                                       2.15.0-7.el10                                                                ol10_appstream                                                               333 k
 fribidi                                                                                    x86_64                                                       1.0.14-4.el10                                                                ol10_appstream                                                               101 k
 gd                                                                                         x86_64                                                       2.3.3-20.el10_0                                                              ol10_appstream                                                               149 k
 gdk-pixbuf2                                                                                x86_64                                                       2.42.12-4.el10_0                                                             ol10_appstream                                                               605 k
 giflib                                                                                     x86_64                                                       5.2.1-22.el10                                                                ol10_appstream                                                                57 k
 google-droid-sans-fonts                                                                    noarch                                                       20200215-22.el10                                                             ol10_appstream                                                               2.7 M
 gpgmepp                                                                                    x86_64                                                       1.23.2-6.el10                                                                ol10_appstream                                                               139 k
 graphviz                                                                                   x86_64                                                       9.0.0-15.el10                                                                ol10_appstream                                                               1.6 M
 highway                                                                                    x86_64                                                       1.2.0-7.el10_0                                                               ol10_u0_developer_EPEL                                                       455 k
 imath                                                                                      x86_64                                                       3.1.10-4.el10                                                                ol10_appstream                                                               104 k
 jasper-libs                                                                                x86_64                                                       4.1.0-5.el10                                                                 ol10_appstream                                                               166 k
 jbig2dec-libs                                                                              x86_64                                                       0.20-7.el10                                                                  ol10_appstream                                                                79 k
 jbigkit-libs                                                                               x86_64                                                       2.1-31.el10                                                                  ol10_appstream                                                                59 k
 lcms2                                                                                      x86_64                                                       2.16-6.el10                                                                  ol10_appstream                                                               188 k
 libXft                                                                                     x86_64                                                       2.3.8-8.el10                                                                 ol10_appstream                                                                77 k
 libXpm                                                                                     x86_64                                                       3.5.17-5.el10                                                                ol10_appstream                                                                70 k
 libXrender                                                                                 x86_64                                                       0.9.11-8.el10                                                                ol10_appstream                                                                28 k
 libdatrie                                                                                  x86_64                                                       0.2.13-11.el10                                                               ol10_appstream                                                                32 k
 libgs                                                                                      x86_64                                                       10.02.1-16.el10_0                                                            ol10_appstream                                                               3.7 M
 libijs                                                                                     x86_64                                                       0.35-24.el10                                                                 ol10_appstream                                                                29 k
 libjpeg-turbo                                                                              x86_64                                                       3.0.2-4.el10                                                                 ol10_appstream                                                               256 k
 libjxl                                                                                     x86_64                                                       1:0.10.4-1.el10_0                                                            ol10_u0_developer_EPEL                                                       1.2 M
 liblerc                                                                                    x86_64                                                       4.0.0-8.el10                                                                 ol10_appstream                                                               221 k
 liblqr-1                                                                                   x86_64                                                       0.4.2-26.el10_0                                                              ol10_u0_developer_EPEL                                                        57 k
 libpaper                                                                                   x86_64                                                       1:2.1.1-7.el10                                                               ol10_appstream                                                                32 k
 libraqm                                                                                    x86_64                                                       0.10.1-1.el10_0                                                              ol10_u0_developer_EPEL                                                        25 k
 librsvg2                                                                                   x86_64                                                       2.57.1-9.el10                                                                ol10_appstream                                                               1.5 M
 libthai                                                                                    x86_64                                                       0.1.29-10.el10                                                               ol10_appstream                                                               219 k
 libtiff                                                                                    x86_64                                                       4.6.0-6.el10_0                                                               ol10_appstream                                                               239 k
 libtool-ltdl                                                                               x86_64                                                       2.4.7-13.el10                                                                ol10_appstream                                                                35 k
 libwebp                                                                                    x86_64                                                       1.3.2-8.el10                                                                 ol10_appstream                                                               298 k
 libwmf-lite                                                                                x86_64                                                       0.2.13-6.el10_0                                                              ol10_u0_developer_EPEL                                                        87 k
 libzip                                                                                     x86_64                                                       1.10.1-5.el10                                                                ol10_appstream                                                                67 k
 openexr-libs                                                                               x86_64                                                       3.1.10-8.el10                                                                ol10_appstream                                                               1.1 M
 openjpeg2                                                                                  x86_64                                                       2.5.2-4.el10_0.1                                                             ol10_appstream                                                               203 k
 pango                                                                                      x86_64                                                       1.54.0-3.el10                                                                ol10_appstream                                                               367 k
 pixman                                                                                     x86_64                                                       0.43.4-2.el10                                                                ol10_appstream                                                               286 k
 poppler                                                                                    x86_64                                                       24.02.0-6.el10                                                               ol10_appstream                                                               1.2 M
 poppler-data                                                                               noarch                                                       0.4.11-9.el10                                                                ol10_appstream                                                               2.2 M
 poppler-glib                                                                               x86_64                                                       24.02.0-6.el10                                                               ol10_appstream                                                               191 k
 rsvg-pixbuf-loader                                                                         x86_64                                                       2.57.1-9.el10                                                                ol10_appstream                                                                15 k
 urw-base35-bookman-fonts                                                                   noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               861 k
 urw-base35-c059-fonts                                                                      noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               888 k
 urw-base35-d050000l-fonts                                                                  noarch                                                       20200910-21.el10                                                             ol10_appstream                                                                80 k
 urw-base35-fonts                                                                           noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               9.5 k
 urw-base35-fonts-common                                                                    noarch                                                       20200910-21.el10                                                             ol10_appstream                                                                20 k
 urw-base35-gothic-fonts                                                                    noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               656 k
 urw-base35-nimbus-mono-ps-fonts                                                            noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               808 k
 urw-base35-nimbus-roman-fonts                                                              noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               870 k
 urw-base35-nimbus-sans-fonts                                                               noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               1.3 M
 urw-base35-p052-fonts                                                                      noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               987 k
 urw-base35-standard-symbols-ps-fonts                                                       noarch                                                       20200910-21.el10                                                             ol10_appstream                                                                45 k
 urw-base35-z003-fonts                                                                      noarch                                                       20200910-21.el10                                                             ol10_appstream                                                               280 k
 xml-common                                                                                 noarch                                                       0.6.3-65.el10                                                                ol10_appstream                                                                42 k

Transaction Summary
=========================================================================================================================================================================================================================================================================================================================
Install  67 Packages

Total download size: 36 M
Installed size: 128 M
Downloading Packages:
<略>
Installed:
  ImageMagick-libs-1:7.1.1.43-1.el10_0.x86_64                   LibRaw-0.21.3-1.el10_0.x86_64                               adobe-mappings-cmap-20230622-5.el10.noarch                 adobe-mappings-cmap-deprecated-20230622-5.el10.noarch       adobe-mappings-pdf-20190401-9.el10.noarch                         
  cairo-1.18.2-2.el10.x86_64                                    cairo-gobject-1.18.2-2.el10.x86_64                          cups-filesystem-1:2.4.10-11.el10.noarch                    cups-libs-1:2.4.10-11.el10.x86_64                           fftw-libs-double-3.3.10-15.el10.x86_64                            
  fontconfig-2.15.0-7.el10.x86_64                               fribidi-1.0.14-4.el10.x86_64                                gd-2.3.3-20.el10_0.x86_64                                  gdk-pixbuf2-2.42.12-4.el10_0.x86_64                         giflib-5.2.1-22.el10.x86_64                                       
  google-droid-sans-fonts-20200215-22.el10.noarch               gpgmepp-1.23.2-6.el10.x86_64                                graphviz-9.0.0-15.el10.x86_64                              highway-1.2.0-7.el10_0.x86_64                               imath-3.1.10-4.el10.x86_64                                        
  jasper-libs-4.1.0-5.el10.x86_64                               jbig2dec-libs-0.20-7.el10.x86_64                            jbigkit-libs-2.1-31.el10.x86_64                            lcms2-2.16-6.el10.x86_64                                    libXft-2.3.8-8.el10.x86_64                                        
  libXpm-3.5.17-5.el10.x86_64                                   libXrender-0.9.11-8.el10.x86_64                             libdatrie-0.2.13-11.el10.x86_64                            libgs-10.02.1-16.el10_0.x86_64                              libijs-0.35-24.el10.x86_64                                        
  libjpeg-turbo-3.0.2-4.el10.x86_64                             libjxl-1:0.10.4-1.el10_0.x86_64                             liblerc-4.0.0-8.el10.x86_64                                liblqr-1-0.4.2-26.el10_0.x86_64                             libpaper-1:2.1.1-7.el10.x86_64                                    
  libraqm-0.10.1-1.el10_0.x86_64                                librsvg2-2.57.1-9.el10.x86_64                               libthai-0.1.29-10.el10.x86_64                              libtiff-4.6.0-6.el10_0.x86_64                               libtool-ltdl-2.4.7-13.el10.x86_64                                 
  libwebp-1.3.2-8.el10.x86_64                                   libwmf-lite-0.2.13-6.el10_0.x86_64                          libzip-1.10.1-5.el10.x86_64                                openexr-libs-3.1.10-8.el10.x86_64                           openjpeg2-2.5.2-4.el10_0.1.x86_64                                 
  pango-1.54.0-3.el10.x86_64                                    php-intl-8.3.19-1.el10_0.x86_64                             php-pecl-imagick-3.8.0-1.el10_0.x86_64                     php-pecl-zip-1.22.3-5.el10.x86_64                           pixman-0.43.4-2.el10.x86_64                                       
  poppler-24.02.0-6.el10.x86_64                                 poppler-data-0.4.11-9.el10.noarch                           poppler-glib-24.02.0-6.el10.x86_64                         rsvg-pixbuf-loader-2.57.1-9.el10.x86_64                     urw-base35-bookman-fonts-20200910-21.el10.noarch                  
  urw-base35-c059-fonts-20200910-21.el10.noarch                 urw-base35-d050000l-fonts-20200910-21.el10.noarch           urw-base35-fonts-20200910-21.el10.noarch                   urw-base35-fonts-common-20200910-21.el10.noarch             urw-base35-gothic-fonts-20200910-21.el10.noarch                   
  urw-base35-nimbus-mono-ps-fonts-20200910-21.el10.noarch       urw-base35-nimbus-roman-fonts-20200910-21.el10.noarch       urw-base35-nimbus-sans-fonts-20200910-21.el10.noarch       urw-base35-p052-fonts-20200910-21.el10.noarch               urw-base35-standard-symbols-ps-fonts-20200910-21.el10.noarch      
  urw-base35-z003-fonts-20200910-21.el10.noarch                 xml-common-0.6.3-65.el10.noarch                            

Complete!
[opc@oci10 ~]$ 

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

手順12: WordPressの.htaccess有効化

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

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

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

[opc@oci10 ~]$ sudo vi /etc/httpd/conf.d/wordpress.conf
[opc@oci10 ~]$ cat /etc/httpd/conf.d/wordpress.conf 
<Directory /var/www/html/wordpress/>
 Allowoverride All
</Directory>
[opc@oci10 ~]$ sudo systemctl restart httpd
[opc@oci10 ~]$ 

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

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

dnf-automatic パッケージをインストールします。

[opc@oci10 ~]$ sudo dnf install dnf-automatic -y
Last metadata expiration check: 1:14:05 ago on Tue 09 Sep 2025 01:42:02 PM JST.
Dependencies resolved.
=========================================================================================================================================================================================================================================================================================================================
 Package                                                                    Architecture                                                        Version                                                                            Repository                                                                       Size
=========================================================================================================================================================================================================================================================================================================================
Installing:
 dnf-automatic                                                              noarch                                                              4.20.0-12.0.1.el10_0                                                               ol10_baseos_latest                                                              191 k

Transaction Summary
=========================================================================================================================================================================================================================================================================================================================
Install  1 Package

Total download size: 191 k
Installed size: 77 k
Downloading Packages:
<略>
Installed:
  dnf-automatic-4.20.0-12.0.1.el10_0.noarch                                                                                                                                                                                                                                                                              

Complete!
[opc@oci10 ~]$ 

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

[opc@oci10 ~]$ sudo vi /etc/dnf/automatic.conf 
[opc@oci10 ~]$ 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

# When the system should reboot following upgrades:
# never                              = don't reboot after upgrades
# when-changed                       = reboot after any changes
# when-needed                        = reboot when necessary to apply changes
reboot = never

# The command that is run to trigger a system reboot.
reboot_command = "shutdown -r +5 'Rebooting after applying package updates'"


[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

# Port number to connect to at the email host.
email_port = 25

# Use TLS or STARTTLS to connect to the email host.
email_tls = no


[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
[opc@oci10 ~]$

そして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 SSL証明書の自動更新設定

dehydratedによるLet’s Encrypt SSL証明書を自動的に更新する設定を行う。

更新した場合だけ、httpdを再起動させたいので /etc/dehydrated/hook.sh の deploy_cert()関数定義のところで「systemctl restart httpd」を追加する

ただ、せっかく /etc/dehydrated/hook.d/ というディレクトリがあり、/etc/dehydrated/hook.shの最後の方で /etc/dehydrated/hook.d/*.sh を読み込んでいるという処理をしているので、そちらで設定を独立させたい。

ということで /etc/dehydrated/hook.d/httpd.sh を作成し、以下を記載

#!/bin/bash

case "$1" in
    "deploy_cert")
        /bin/systemctl restart httpd
    ;;
esac

exit 0

強制的にSSL証明書再発行を実行「sudo dehydrated –cron –force」

[opc@oci10 ~]$ sudo dehydrated --cron --force
# INFO: Using main config file /etc/dehydrated/config
# INFO: Using additional config file /etc/dehydrated/conf.d/local.sh
Processing <ホスト名>
 + Checking expire date of existing cert...
 + Valid till Dec  9 01:51:44 2025 GMT (Longer than 30 days). Ignoring because renew was forced!
 + Signing domains...
 + Generating signing request...
 + Requesting new certificate order from CA...
 + Received 1 authorizations URLs from the CA
 + Handling authorization for <ホスト名>
 + Found valid authorization for <ホスト名>
 + 0 pending challenge(s)
 + Requesting certificate...
Warning: Will read cert request from stdin since no -in option is given
 + Checking certificate...
 + Done!
 + Creating fullchain.pem...
 + Done!
 + Running automatic cleanup
Moving unused file to archive directory: <ホスト名>/cert-1757472608.csr
Moving unused file to archive directory: <ホスト名>/cert-1757472608.pem
Moving unused file to archive directory: <ホスト名>/chain-1757472608.pem
Moving unused file to archive directory: <ホスト名>/fullchain-1757472608.pem
[opc@oci10 ~]$

ちゃんとhttpdが再起動しているかを「systemctl status httpd」を実行して確認

下記の「Active:」のsinceの後ろの時刻がつい最近であることを確認する

[opc@oci10 ~]$ systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
    Drop-In: /etc/systemd/system/httpd.service.d
             └─php-fpm.conf
     Active: active (running) since Wed 2025-09-10 11:51:21 JST; 7s ago
 Invocation: cae425cfbaae4ba68fa746588b2dde05
       Docs: man:httpd.service(8)
   Main PID: 110426 (httpd)
     Status: "Started, listening on: port 443, port 80"
      Tasks: 177 (limit: 5249)
     Memory: 14.6M (peak: 14.8M)
        CPU: 216ms
     CGroup: /system.slice/httpd.service
             ├─110426 /usr/sbin/httpd -DFOREGROUND
             ├─110427 /usr/sbin/httpd -DFOREGROUND
             ├─110428 /usr/sbin/httpd -DFOREGROUND
             ├─110429 /usr/sbin/httpd -DFOREGROUND
             └─110430 /usr/sbin/httpd -DFOREGROUND

Sep 10 11:51:21 oci10 systemd[1]: Starting httpd.service - The Apache HTTP Server...
Sep 10 11:51:21 oci10 (httpd)[110426]: httpd.service: Referenced but unset environment variable evaluates to an empty string: OPTIONS
Sep 10 11:51:21 oci10 systemd[1]: Started httpd.service - The Apache HTTP Server.
Sep 10 11:51:21 oci10 httpd[110426]: Server configured, listening on: port 443, port 80
[opc@oci10 ~]$ 

次にdehydratedが定期的に実行される設定になっているかを「systemctl status dehydrated.timer」を実行して確認する

[opc@oci10 ~]$ systemctl status dehydrated.timer
● dehydrated.timer - dehydrated client for signing certificates with an ACME server
     Loaded: loaded (/usr/lib/systemd/system/dehydrated.timer; enabled; preset: enabled)
     Active: active (waiting) since Tue 2025-09-09 14:07:18 JST; 21h ago
 Invocation: d81b66fc4dd943368689b90f756ab156
    Trigger: Thu 2025-09-11 01:41:37 JST; 13h left
   Triggers: ● dehydrated.service

Sep 09 14:07:18 oci10 systemd[1]: Started dehydrated.timer - dehydrated client for signing certificates with an ACME server.
[opc@oci10 ~]$ 

Oracle Linux 10においては標準でenabledとなっているので、自動的に実行されるようになっていた。

(dehydrated.service は disable だが、これはdehydrated.timer から起動されるやつなのでそのままで良い)


トラブル対応手順1: python3-pyOpenSSLのconflict問題

2025/09/19時点ではdnf updateが失敗した。(2026/04/30に実施した際はこの問題は発生しなかった)

[opc@oci10 ~]$ sudo dnf update -y
Last metadata expiration check: 1:18:42 ago on Fri 19 Sep 2025 12:26:32 PM JST.
Error: 
 Problem: package python3-oci-sdk-2.159.0-1.el10.x86_64 from ol10_oci_included requires (python3.12dist(pyopenssl) &lt; 25~~ with python3.12dist(pyopenssl) >= 17.5), but none of the providers can be installed
  - cannot install both python3-pyOpenSSL-25.0.0-1.el10_0.noarch from ol10_u0_developer_EPEL and python3-pyOpenSSL-24.2.1-1.0.1.el10.noarch from @System
  - cannot install both python3-pyOpenSSL-25.0.0-1.el10_0.noarch from ol10_u0_developer_EPEL and python3-pyOpenSSL-24.2.1-1.el10_0.noarch from ol10_u0_developer_EPEL
  - cannot install both python3-pyOpenSSL-24.2.1-1.0.1.el10.noarch from ol10_appstream and python3-pyOpenSSL-25.0.0-1.el10_0.noarch from ol10_u0_developer_EPEL
  - cannot install the best update candidate for package python3-pyOpenSSL-24.2.1-1.0.1.el10.noarch
  - cannot install the best update candidate for package python3-oci-sdk-2.158.0-1.el10.x86_64
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
[opc@oci10 ~]$

python3-pyOpenSSLがOracle Linux 10標準提供の python3-pyOpenSSL-24.2.1 系列と、EPEL提供の python3-pyOpenSSL-25.0.0 系列の2種類があるために発生している模様

とりあえず、EPEL側のpython3-pyOpenSSL-25.0.0 を使用しないようにしたところ、問題はなさそう。

設定は /etc/yum.repos.d/oracle-epel-ol10.repoに「exclude=python3-pyOpenSSL*」を追加する

[opc@oci10 ~]$ cat /etc/yum.repos.d/oracle-epel-ol10.repo 
[ol10_u0_developer_EPEL]
name=Oracle Linux $releasever.0 EPEL Packages for Development ($basearch)
baseurl=https://yum$ociregion.$ocidomain/repo/OracleLinux/OL10/0/developer/EPEL/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
exclude=python3-pyOpenSSL*
[opc@oci10 ~]$ 

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ドキュメント


Firewall内のCentOSからhttps://mirror.centos.org/にアクセスできなかった件

FortigateによるFirewall内にあるCentOS9サーバから「dnf check-update」を実行してみたところ、失敗した。

[root@centos9 ~]# dnf update
サブスクリプション管理リポジトリーを更新しています。
コンシューマー識別子を読み込めません

このシステムは、エンタイトルメントサーバーに登録されていません。subscription-manager で登録できます。

CentOS Stream 9 - BaseOS                        0.0  B/s |   0  B     00:03
Errors during downloading metadata for repository 'baseos':
  - Curl error (60): SSL peer certificate or SSH remote key was not OK for https://mirrors.centos.org/metalink?repo=centos-baseos-9-stream&amp;arch=x86_64&amp;protocol=https,http [SSL certificate problem: self-signed certificate in certificate chain]
エラー: repo 'baseos' のメタデータのダウンロードに失敗しました : Cannot prepare internal mirrorlist: Curl error (60): SSL peer certificate or SSH remote key was not OK for https://mirrors.centos.org/metalink?repo=centos-baseos-9-stream&amp;arch=x86_64&amp;protocol=https,http [SSL certificate problem: self-signed certificate in certificate chain]
[root@centos9 ~]#

内容的には https://mirrors.centos.org/ へのアクセスでエラーになっていたので、curlコマンドで状況を確認してみることにした。

[root@centos9 ~]# curl -vvv https://mirrors.centos.org/publiclist/
*   Trying 13.125.120.8:443...
* Connected to mirrors.centos.org (13.125.120.8) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
*  CAfile: /etc/pki/tls/certs/ca-bundle.crt
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS header, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS header, Finished (20):
* TLSv1.2 (IN), TLS header, Unknown (23):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.2 (IN), TLS header, Unknown (23):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS header, Unknown (21):
* TLSv1.3 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: self-signed certificate in certificate chain
* Closing connection 0
curl: (60) SSL certificate problem: self-signed certificate in certificate chain
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
[root@centos9 ~]#

同じ環境にあるCentOS7サーバやOracle Linux8サーバでも同じ結果になった。

他の環境にあるCentOS7サーバで実行してみると下記のような感じになった。

-bash-4.2$ curl -vvv https://mirrors.centos.org/publiclist/
* About to connect() to mirrors.centos.org port 443 (#0)
*   Trying 2620:52:3:1:dead:beef:cafe:fed6...
* Connected to mirrors.centos.org (2620:52:3:1:dead:beef:cafe:fed6) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=mirrors.centos.org
*       start date: 10月 19 06:06:54 2021 GMT
*       expire date:  1月 17 06:06:53 2022 GMT
*       common name: mirrors.centos.org
*       issuer: CN=R3,O=Let's Encrypt,C=US
> GET /publiclist/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: mirrors.centos.org
> Accept: */*
>
&lt; HTTP/1.1 302 Found
&lt; Date: Fri, 12 Nov 2021 08:44:59 GMT
&lt; Server: Apache
&lt; X-Frame-Options: SAMEORIGIN
&lt; X-Xss-Protection: 1; mode=block
&lt; X-Content-Type-Options: nosniff
&lt; Referrer-Policy: same-origin
&lt; Location: https://admin.fedoraproject.org/mirrormanager/
&lt; Content-Length: 299
&lt; Content-Type: text/html; charset=iso-8859-1
&lt;
&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
&lt;html>&lt;head>
&lt;title>302 Found&lt;/title>
&lt;/head>&lt;body>
&lt;h1>Found&lt;/h1>
&lt;p>The document has moved &lt;a href="https://admin.fedoraproject.org/mirrormanager/">here&lt;/a>.&lt;/p>
&lt;hr>
&lt;address>Apache Server at mirrors.centos.org Port 443&lt;/address>
&lt;/body>&lt;/html>
* Connection #0 to host mirrors.centos.org left intact
-bash-4.2$

Let’s Encryptの証明書使ってるな、ということで、同じ環境にあるブラウザからアクセスしてみると、Fortigateによるhttps周りの動作の問題であることが判明

解決方法は「FortiGate環境で”This Connection is Invalid. SSL certificate expired.”を食らった」にあるやつと同じでした。

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

(Oracle Linux 9向けのWordpress設定手順はこちら)

Oracle CloudのAlways Freeで作れるインスタンスにARMベースのインスタンスが追加された。

従来のCPU1個/メモリ1GBに対して、CPU1~4個/メモリ6GB~24GBと破格のスペックなので、Wordpressサーバでも移行してみるかな、と思って、「CentOS 7 / Oracle Linux 7でWordPressサーバを建てる」の手順でつくろうとしてみたところ、Oracle Linux 7 ARMではPHP Packages for Oracle Linuxが提供されていなかった。

Oracle Linux 8であれば標準状態でphp 7.4が利用できるようなので、Oracle Linux 8で作成する手順を策定した。

変更履歴

・Wordpress本体を更新しようとしたらできなかったので「手順8-2: php-fpmの書き込み権限問題」追加
・既存blogのデータをインポートしようとしたらファイルサイズオーバーだったので「手順9: WordPressで取り扱えるファイルサイズの拡大」追加
・存在を思い出したので「手順10: WordPressのSite Health Status対応」追加
・パーマリンク設定を変更したら動かなかったので「手順11: WordPressの.htaccess有効化」追加
・「手順12: OS自動更新の設定」追加
・日本語Localeに設定した場合の対応として「手順2-3:日本語Locale対応」追加
・2022/04/06にOracle-Linux-8.5-aarch64-2022.03.17-1を使って構築した時の状況を追加
・手順8が2つあったので番号を振り直した
・wordpressにWP Multibyte Patchをインストールする手順を書き忘れていたので追加

また、手順8以降でWordpressにアクセスすると「Service Unavailable」と表示される場合があります。その場合は、php-fpmのSELinuxポリシー設定問題であるため「Oracle Linux 8でphp 7.4.19-1にアップデート後からphp-fpmが起動しなくなった」の対処を行ってみてください。

準備1: Oracle Cloud用手順

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

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

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

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

2021年5月27日の段階ではOracle Cloud環境で提供されるOracle Linux 8でIPv6アドレスの自動割り当てが動作していませんでした。

Oracle-Linux-8.5-aarch64-2022.03.17-1(2022/04/06時点)やOracle-Linux-8.6-aarch64-2022.05.30-0(2022/07/01時点)でも同様でした。

このため、firewalldの設定でdhcpv6-clientが許可されていないために発生していましたので、許可します。

まず初期状態を確認

$ sudo firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3
  sources:
  services: ssh
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
$

dhcpv6-clientの許可設定と設定読み込みと確認

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

準備2: 一般的な前準備

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

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

$ sudo timedatectl set-timezone Japan
$ 

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

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

Oracle Linux 8では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
<略>
$

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

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

Oracle Cloud上のOracle Linux 8環境ではレポジトリパッケージのインストールはされているので、有効化を行います。(なお、/etc/yum.repo.d/のファイルを編集するのは時代遅れな操作です)

また、2021年11月以降のOracle Cloudでの新規インスタンスではOS管理が有効になっている関係で手順が変わっています。新規で作る場合は手順3-1bの方を参照してください。

手順3-1a:通常の手順

Oracle Cloud外の環境でOracle Linux 8をインストールしている場合や古めのOracle Cloudインスタンスの場合、こちらのOS側のコマンドで設定する手順を行います。

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

$ sudo dnf repolist --all
repo id                          repo name                              status
ol8_MySQL80                      MySQL 8.0 for Oracle Linux 8 (aarch64) enabled
ol8_MySQL80_connectors_community MySQL 8.0 Connectors Community for Ora enabled
ol8_MySQL80_tools_community      MySQL 8.0 Tools Community for Oracle L enabled
ol8_aarch64_userspace_ksplice    Ksplice aware userspace packages for O disabled
ol8_appstream                    Oracle Linux 8 Application Stream (aar enabled
ol8_baseos_latest                Oracle Linux 8 BaseOS Latest (aarch64) enabled
ol8_codeready_builder            Oracle Linux 8 CodeReady Builder (aarc disabled
ol8_developer                    Oracle Linux 8 Development Packages (a disabled
ol8_developer_EPEL               Oracle Linux 8 EPEL Packages for Devel disabled
ol8_developer_UEKR6              Developer Preview of UEK Release 6 (aa disabled
ol8_distro_builder               Oracle Linux 8 Distro Builder (aarch64 disabled
ol8_ksplice                      Ksplice for Oracle Linux 8 (aarch64)   enabled
ol8_oci_included                 Oracle Software for OCI users on Oracl enabled
ol8_u2_baseos_base               Oracle Linux 8.2 BaseOS (aarch64)      disabled
ol8_u3_baseos_base               Oracle Linux 8.3 BaseOS (aarch64)      disabled
ol8_u4_baseos_base               Oracle Linux 8.4 BaseOS (aarch64)      disabled
$ 

上記の場合、ol8_developer_EPELが登録されているもののdisabledになっています。

この場合は「sudo dnf config-manager –set-enabled ol8_developer_EPEL」を実行し、enabledに変更されたことを確認します。

$ sudo dnf config-manager --set-enabled ol8_developer_EPEL
$ sudo dnf repolist --all
repo id                          repo name                              status
ol8_MySQL80                      MySQL 8.0 for Oracle Linux 8 (aarch64) enabled
ol8_MySQL80_connectors_community MySQL 8.0 Connectors Community for Ora enabled
ol8_MySQL80_tools_community      MySQL 8.0 Tools Community for Oracle L enabled
ol8_aarch64_userspace_ksplice    Ksplice aware userspace packages for O disabled
ol8_appstream                    Oracle Linux 8 Application Stream (aar enabled
ol8_baseos_latest                Oracle Linux 8 BaseOS Latest (aarch64) enabled
ol8_codeready_builder            Oracle Linux 8 CodeReady Builder (aarc disabled
ol8_developer                    Oracle Linux 8 Development Packages (a disabled
ol8_developer_EPEL               Oracle Linux 8 EPEL Packages for Devel enabled
ol8_developer_UEKR6              Developer Preview of UEK Release 6 (aa disabled
ol8_distro_builder               Oracle Linux 8 Distro Builder (aarch64 disabled
ol8_ksplice                      Ksplice for Oracle Linux 8 (aarch64)   enabled
ol8_oci_included                 Oracle Software for OCI users on Oracl enabled
ol8_u2_baseos_base               Oracle Linux 8.2 BaseOS (aarch64)      disabled
ol8_u3_baseos_base               Oracle Linux 8.3 BaseOS (aarch64)      disabled
ol8_u4_baseos_base               Oracle Linux 8.4 BaseOS (aarch64)      disabled
$

手順3-1b:Oracle CloudのOS管理下にある場合の手順

2022年4月6日時点でOracle Cloud上で提供されているOracle-Linux-8.5-aarch64-2022.03.17-1では「sudo dnf repolist –all」の実行結果に変化があり、「This system is receiving updates from OSMS server.」と書かれた上で、だいぶ整理されたレポジトリのみが表示されます。

$ sudo dnf repolist --all
This system is receiving updates from OSMS server.
repo id                                  repo name                       status
ol8_addons-aarch64                       Oracle Linux 8 Add ons (aarch64 enabled
ol8_appstream-aarch64                    Oracle Linux 8 Application Stre enabled
ol8_baseos_latest-aarch64                Oracle Linux 8 BaseOS Latest (a enabled
ol8_ksplice-aarch64                      Ksplice for Oracle Linux 8 (aar enabled
ol8_mysql80-aarch64                      MySQL 8.0 for Oracle Linux 8 (a enabled
ol8_mysql80_connectors_community-aarch64 MySQL 8.0 Connectors for Oracle enabled
ol8_mysql80_tools_community-aarch64      MySQL 8.0 Tools Community for O enabled
ol8_oci_included-aarch64                 Oracle Software for OCI users o enabled
$

これはOracle Cloudの「OS管理(OS Managemnt System)」という機能との連携が始まり、Oracle CloudのWebコンソール からパッチ状態を見れるように変更になったためです。

レポジトリの設定変更は上記画面の「…」をクリックし「OS管理詳細の表示」を選択

[リソース]-[ソフトウェア・ソース]から「追加」を選択

「Oralce Linux 8 EPEL Packages for Development」を選択し「追加」

Web上で追加されたことを確認

次にコマンドに戻り「sudo dnf repolist –all」を実行するとEPELレポジトリがenabledとして増えていることが確認できます。

$ sudo dnf repolist --all
This system is receiving updates from OSMS server.
repo id                                  repo name                       status
ol8_addons-aarch64                       Oracle Linux 8 Add ons (aarch64 enabled
ol8_appstream-aarch64                    Oracle Linux 8 Application Stre enabled
ol8_baseos_latest-aarch64                Oracle Linux 8 BaseOS Latest (a enabled
ol8_developer_epel-aarch64               Oracle Linux 8 EPEL Packages fo enabled
ol8_ksplice-aarch64                      Ksplice for Oracle Linux 8 (aar enabled
ol8_mysql80-aarch64                      MySQL 8.0 for Oracle Linux 8 (a enabled
ol8_mysql80_connectors_community-aarch64 MySQL 8.0 Connectors for Oracle enabled
ol8_mysql80_tools_community-aarch64      MySQL 8.0 Tools Community for O enabled
ol8_oci_included-aarch64                 Oracle Software for OCI users o enabled

手順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 fail2ban
$ sudo systemctl start 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: enp0s3
  sources:
  services: dhcpv6-client ssh
  ports:
  protocols:
  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: enp0s3
  sources:
  services: dhcpv6-client http https ssh
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
$

手順5: php 7.4追加

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

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

$ sudo dnf module list | grep php
php                  7.2 [d]         common [d], devel, minimal               PHP scripting language                                                                                                                                                                                
php                  7.3             common [d], devel, minimal               PHP scripting language                                                                                                                                                                                
php                  7.4             common [d], devel, minimal               PHP scripting language                                                                                                                                                                                
$

php 7.2が標準選択で、他にphp 7.3とphp 7.4が選べることがわかります。
2022/07/01時点で提供されているOracle Linux 8.6では php 8.0も選択できるようになっています。

php7.4を指定してパッケージを追加します。

$ sudo dnf install @php:7.4 -y
Last metadata expiration check: 0:07:11 ago on Thu 27 May 2021 01:04:16 PM JST.
Dependencies resolved.
==========================================================================================================================================
 Package                     Architecture       Version                                                Repository                    Size
==========================================================================================================================================
Installing group/module packages:
 php-cli                     aarch64            7.4.6-4.module+el8.3.0+7685+72d70b58                   ol8_appstream                2.8 M
 php-common                  aarch64            7.4.6-4.module+el8.3.0+7685+72d70b58                   ol8_appstream                675 k
 php-fpm                     aarch64            7.4.6-4.module+el8.3.0+7685+72d70b58                   ol8_appstream                1.5 M
 php-json                    aarch64            7.4.6-4.module+el8.3.0+7685+72d70b58                   ol8_appstream                 73 k
 php-mbstring                aarch64            7.4.6-4.module+el8.3.0+7685+72d70b58                   ol8_appstream                474 k
 php-xml                     aarch64            7.4.6-4.module+el8.3.0+7685+72d70b58                   ol8_appstream                166 k
Installing dependencies:
 httpd-filesystem            noarch             2.4.37-39.0.1.module+el8.4.0+20024+b87b2deb            ol8_appstream                 39 k
 libxslt                     aarch64            1.1.32-6.0.1.el8                                       ol8_baseos_latest            239 k
 nginx-filesystem            noarch             1:1.14.1-9.0.1.module+el8.0.0+5347+9282027e            ol8_appstream                 25 k
Installing module profiles:
 php/common
Enabling module streams:
 httpd                                          2.4
 nginx                                          1.14
 php                                            7.4

Transaction Summary
==========================================================================================================================================
Install  9 Packages

Total download size: 5.9 M
Installed size: 23 M
Downloading Packages:
<略>
$

手順6: MySQL設定編

Oralce Linux 8ではわざわざ「MySQL 8.0 for Oracle Linux 8 (aarch64)」を用意していますが、よく見るとそこにmysql-serverはなく、メインのol8_appstream に含まれているという理由はよくわかりませんが、せっかくなのでそのまま使用します。

(ちなみにol8_appstreamではmariadb 10.3と10.5も提供されていますので変更することもできます)

$ sudo dnf install mysql-server -y
Last metadata expiration check: 0:56:46 ago on Thu 27 May 2021 01:04:16 PM JST.
Dependencies resolved.
================================================================================
 Package      Arch    Version                               Repository     Size
================================================================================
Installing:
 mysql-server aarch64 8.0.21-1.module+el8.2.0+7793+cfe2b687 ol8_appstream  28 M
Installing dependencies:
 mariadb-connector-c-config
              noarch  3.1.11-2.el8_3                        ol8_appstream  15 k
 mecab        aarch64 0.996-1.module+el8.0.0+5253+1dce7bb2.9
                                                            ol8_appstream 367 k
 mysql        aarch64 8.0.21-1.module+el8.2.0+7793+cfe2b687 ol8_appstream  13 M
 mysql-common aarch64 8.0.21-1.module+el8.2.0+7793+cfe2b687 ol8_appstream 147 k
 mysql-errmsg aarch64 8.0.21-1.module+el8.2.0+7793+cfe2b687 ol8_appstream 581 k
 protobuf-lite
              aarch64 3.5.0-13.el8                          ol8_appstream 129 k
Enabling module streams:
 mysql                8.0

Transaction Summary
================================================================================
Install  7 Packages

Total download size: 42 M
Installed size: 228 M
Downloading Packages:
<略>
$

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

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

mysqldを起動します。

$ sudo systemctl start mysqld
$

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.21 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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.00 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 8では httpd(Apache) 2.4と nginx 1.14 / 1.16 / 1.18 が使用できますが、httpdを使用します。nginxを使用したい場合は「Oracle Autonomous Linuxでwordpressサーバを建ててみた」を参照してください。

$ sudo dnf install httpd -y
Last metadata expiration check: 0:08:49 ago on Thu 27 May 2021 01:04:16 PM JST.
Dependencies resolved.
==========================================================================================================================================
 Package                      Architecture      Version                                                 Repository                   Size
==========================================================================================================================================
Installing:
 httpd                        aarch64           2.4.37-39.0.1.module+el8.4.0+20024+b87b2deb             ol8_appstream               1.4 M
Installing dependencies:
 apr                          aarch64           1.6.3-11.el8                                            ol8_appstream               119 k
 apr-util                     aarch64           1.6.1-6.el8                                             ol8_appstream               104 k
 httpd-tools                  aarch64           2.4.37-39.0.1.module+el8.4.0+20024+b87b2deb             ol8_appstream               104 k
 mod_http2                    aarch64           1.15.7-3.module+el8.4.0+20024+b87b2deb                  ol8_appstream               146 k
 oracle-logos-httpd           noarch            84.3-1.0.1.el8                                          ol8_baseos_latest            29 k

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

Total download size: 1.8 M
Installed size: 10 M
Downloading Packages:
<略>
$

次で設定変更をするので、この段階では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: 1:07:45 ago on Thu 27 May 2021 01:04:16 PM JST.
Dependencies resolved.
================================================================================
 Package          Architecture Version           Repository                Size
================================================================================
Installing:
 dehydrated       noarch       0.6.5-1.el8       ol8_developer_EPEL        90 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 90 k
Installed size: 164 k
Downloading Packages:
<略>
$

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.2-November-15-2017.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 ID...
+ Done!
$

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

$ sudo dehydrated --cron
# INFO: Using main config file /etc/dehydrated/config
# INFO: Using additional config file /etc/dehydrated/conf.d/local.sh
Processing ホスト1名.ドメイン名 with alternative names: ホスト2名.ドメイン名
 + 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!
$

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

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

$ sudo dnf install mod_ssl -y
Last metadata expiration check: 1:36:21 ago on Thu 27 May 2021 01:04:16 PM JST.
Dependencies resolved.
================================================================================
 Package
      Arch    Version                                       Repository     Size
================================================================================
Installing:
 mod_ssl
      aarch64 1:2.4.37-39.0.1.module+el8.4.0+20024+b87b2deb ol8_appstream 126 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 126 k
Installed size: 274 k
Downloading Packages:
<略>
$

標準の /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 2021-05-27, Mozilla Guideline v5.6, Apache 2.4.37, OpenSSL 1.1.1g, intermediate configuration
# https://ssl-config.mozilla.org/#server=apache&version=2.4.37&config=intermediate&openssl=1.1.1g&guideline=5.6

# this configuration requires mod_ssl, mod_socache_shmcb, mod_rewrite, and mod_headers
<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/\.well\-known/acme\-challenge/
    RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,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 -SSLv3 -TLSv1 -TLSv1.1
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
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 15.0M  100 15.0M    0     0  6978k      0  0:00:02  0:00:02 --:--:-- 6978k
$ ls
latest.tar.gz
$ sudo tar xfz latest.tar.gz
$ ls -l
total 15388
-rw-r--r--. 1 root   root   15750424 May 27 14:54 latest.tar.gz
drwxr-xr-x. 5 nobody nobody     4096 May 13 08:49 wordpress
$ sudo rm latest.tar.gz
$

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

$ ps -ef|grep http
root        7619       1  0 14:52 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache      7621    7619  0 14:52 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache      7622    7619  0 14:52 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache      7623    7619  0 14:52 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache      7624    7619  0 14:52 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache      7836    7619  0 14:52 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
opc         7943    2643  0 14:55 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 May 13 08:49 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 2021-05-27, Mozilla Guideline v5.6, Apache 2.4.37, OpenSSL 1.1.1g, intermediate configuration
# https://ssl-config.mozilla.org/#server=apache&version=2.4.37&config=intermediate&openssl=1.1.1g&guideline=5.6

# this configuration requires mod_ssl, mod_socache_shmcb, mod_rewrite, and mod_headers
<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/\.well\-known/acme\-challenge/
    RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,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 -SSLv3 -TLSv1 -TLSv1.1
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
SSLHonorCipherOrder     off
SSLSessionTickets       off

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

手順8-2:「Service Unavailable」となる場合の対処

ブラウザからアクセスして「Service Unavailable」となる場合はphp-fpmのSELinux設定問題が発生しています。

httpd_execmemを有効にします。

$ getsebool httpd_execmem
httpd_execmem --> off
$ sudo setsebool -P httpd_execmem on
$ sudo getsebool httpd_execmem
httpd_execmem --> on
$

次に、php-fpm用のSELinux設定を作成します。まず「sudo ausearch -m AVC |grep php |audit2allow」を実行して「allow ~」の出力があることを確認

$ sudo ausearch -m AVC |grep php |audit2allow


#============= httpd_t ==============
allow httpd_t httpd_exec_t:file execmod;
$

次にこれを使ってSELinux用のモジュールを作成

$ sudo ausearch -m AVC |grep php |sudo audit2allow -M ph
p-fpm
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i php-fpm.pp

$ ls
php-fpm.pp  php-fpm.te  wordpress
$

モジュールとして組み込みphp-fpmを起動

$ sudo semodule -i php-fpm.pp
$ sudo systemctl start php-fpm
$ 

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

php-fpmが正常に動作している状態でブラウザからアクセスすると、下記の表示になります。

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

$ sudo dnf install php-mysqlnd -y
Last metadata expiration check: 1:56:37 ago on Thu 27 May 2021 01:04:16 PM JST.
Dependencies resolved.
================================================================================
 Package     Arch    Version                                Repository     Size
================================================================================
Installing:
 php-mysqlnd aarch64 7.4.6-4.module+el8.3.0+7685+72d70b58   ol8_appstream 182 k
Installing dependencies:
 php-pdo     aarch64 7.4.6-4.module+el8.3.0+7685+72d70b58   ol8_appstream 118 k

Transaction Summary
================================================================================
Install  2 Packages

Total download size: 300 k
Installed size: 806 k
Downloading Packages:
<略>
$ sudo systemctl restart httpd
$

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

手順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(1622101524.977:177): avc:  denied  { write } for  pid=2964 comm="php-fpm" name="wordpress" dev="dm-0" ino=101235463 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 May 27 15:02 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 May 27 15:02 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 8の標準設定では下記の値となっている。

<略>
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」を実行します。

手順11: WordPressのSite Health Status対応

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

ImageMagickに関するphpモジュールは含まれていない

$ dnf search magick
Last metadata expiration check: 2:56:09 ago on Thu 27 May 2021 01:10:22 PM JST.
======================== Name & Summary Matched: magick ========================
GraphicsMagick.aarch64 : An ImageMagick fork, offering faster image generation
                       : and better quality
GraphicsMagick.src : An ImageMagick fork, offering faster image generation and
                   : better quality
GraphicsMagick-c++.aarch64 : GraphicsMagick Magick++ library (C++ bindings)
GraphicsMagick-c++-devel.aarch64 : C++ bindings for the GraphicsMagick library
GraphicsMagick-debugsource.aarch64 : Debug sources for package GraphicsMagick
GraphicsMagick-devel.aarch64 : Libraries and header files for GraphicsMagick app
                             : development
GraphicsMagick-doc.noarch : GraphicsMagick documentation
GraphicsMagick-perl.aarch64 : GraphicsMagick perl bindings
ImageMagick-c++.aarch64 : ImageMagick Magick++ library (C++ bindings)
ImageMagick-c++-devel.aarch64 : C++ bindings for the ImageMagick library
ImageMagick-devel.aarch64 : Library links and header files for ImageMagick app
                          : development
ImageMagick-doc.aarch64 : ImageMagick html documentation
ImageMagick-libs.aarch64 : ImageMagick libraries to link with
ImageMagick-perl.aarch64 : ImageMagick perl bindings
============================= Name Matched: magick =============================
ImageMagick.aarch64 : An X application for displaying and manipulating images
ImageMagick.src : An X application for displaying and manipulating images
=========================== Summary Matched: magick ============================
converseen.aarch64 : A batch image conversion tool written in C++ with Qt5 and
                   : Magick++
converseen.src : A batch image conversion tool written in C++ with Qt5 and
               : Magick++
$

zipとgdはそれっぽいものがあるので「sudo dnf install php-pecl-zip php-gd -y」で追加

$ sudo dnf install php-pecl-zip php-gd -y
Last metadata expiration check: 3:04:44 ago on Thu 27 May 2021 01:04:16 PM JST.
Dependencies resolved.
================================================================================
 Package      Arch    Version                               Repository     Size
================================================================================
Installing:
 php-gd       aarch64 7.4.6-4.module+el8.3.0+7685+72d70b58  ol8_appstream  83 k
 php-pecl-zip aarch64 1.18.2-1.module+el8.3.0+7685+72d70b58 ol8_appstream  53 k
Installing dependencies:
 gd           aarch64 2.2.5-7.el8                           ol8_appstream 134 k
 jbigkit-libs aarch64 2.1-14.el8                            ol8_appstream  54 k
 libXpm       aarch64 3.5.12-8.el8                          ol8_appstream  56 k
 libjpeg-turbo
              aarch64 1.5.3-10.el8                          ol8_appstream 145 k
 libtiff      aarch64 4.0.9-18.el8                          ol8_appstream 178 k
 libwebp      aarch64 1.0.0-1.el8                           ol8_appstream 246 k
 libzip       aarch64 1.6.1-1.module+el8.3.0+7685+72d70b58  ol8_appstream  62 k

Transaction Summary
================================================================================
Install  9 Packages

Total download size: 1.0 M
Installed size: 3.0 M
Downloading Packages:
<略>
$

こちらは再起動は不要なようで、すぐにSite Healthの状態に反映され、imagickモジュールに関するメッセージのみになった。

2022/04/06追記: wordpress 5.9.3では推奨phpプラグインに「php-intl」が追加されたので「sudo dnf install php-intl」で追加する

$ sudo dnf install php-intl
This system is receiving updates from OSMS server.
Last metadata expiration check: 0:09:17 ago on Wed 06 Apr 2022 01:29:10 PM JST.
Dependencies resolved.
================================================================================
 Package
     Arch    Version                                Repository             Size
================================================================================
Installing:
 php-intl
     aarch64 7.4.19-1.module+el8.5.0+20354+db97279a ol8_appstream-aarch64 182 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 182 k
Installed size: 522 k
Is this ok [y/N]: y
Downloading Packages:
php-intl-7.4.19-1.module+el8.5.0+20354+db97279a 2.0 MB/s | 182 kB     00:00
--------------------------------------------------------------------------------
Total                                           1.9 MB/s | 182 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : php-intl-7.4.19-1.module+el8.5.0+20354+db97279a.aarc   1/1
  Running scriptlet: php-intl-7.4.19-1.module+el8.5.0+20354+db97279a.aarc   1/1
  Verifying        : php-intl-7.4.19-1.module+el8.5.0+20354+db97279a.aarc   1/1

Installed:
  php-intl-7.4.19-1.module+el8.5.0+20354+db97279a.aarch64

Complete!
$

手順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:21:33 ago on Wed 02 Jun 2021 05:00:20 PM JST.
Dependencies resolved.
================================================================================
 Package            Arch        Version            Repository              Size
================================================================================
Installing:
 dnf-automatic      noarch      4.4.2-11.el8       ol8_baseos_latest      148 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 148 k
Installed size: 51 k
Downloading Packages:
<略>
$

/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; vendo>
   Active: inactive (dead)
$ 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; vendor>
   Active: active (waiting) since Wed 2021-06-02 17:26:38 JST; 2s ago
  Trigger: Thu 2021-06-03 06:07:23 JST; 12h left

Jun 02 17:26:38 ホスト名 systemd[1]: Started dnf-automatic timer.
$

なお、dnf automaticでアップデートされた場合に、通知メールを送るようにする場合は、「Oracle Cloud上のインスタンスから管理メールを送信する手法」を参照のこと。

CentOS 7 / Oracle Linux 7でWordPressサーバを建てる

この間、Oracle Linux 7ベースのOracle Autonomouse Linux 環境にWordPressサーバを建てる手順を書いたけど、そういえばベースとなるCent OS 7(Oracle Linux 7)環境でWordpressサーバを建てる手順を書いたことなかったな、と書いてみる。

前準備

CentOS7として基本的な設定を行っていく。

準備1:パッケージのアップデート

インストール済みのパッケージを最新にするため「yum update」を実行する

$ sudo yum update -y

準備2:日本時間にする

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

$ sudo timedatectl set-timezone Japan

変更されたことを確認するには「timedatectl」を実行する。

$ timedatectl
      Local time: Tue 2020-07-07 10:04:40 JST
  Universal time: Tue 2020-07-07 01:04:40 UTC
        RTC time: Tue 2020-07-07 01:04:38
       Time zone: Japan (JST, +0900)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
$

準備3:パッケージの自動アップデート設定をする

方針にもよりますが、最近は死ぬパッケージが配布されることは少ないので、自動アップデートしてしまえ、と、yum-cronによる自動アップデート設定を入れています。

まず、yum-cron パッケージをインストールします。

$ sudo yum install yum-cron

次に /etc/yum/yum-cron.conf を編集して自動アップデートを有効にします。

$ sudo vi /etc/yum/yum-cron.conf

ファイル内にある「apply_updates = no」を「apply_updates = yes」に変更します。

変更後の該当部分は以下の様になります。

# Whether updates should be applied when they are available.  Note
# that download_updates must also be yes for the update to be applied.
apply_updates = yes

準備4:EPELレポジトリの追加

EPELレポジトリが必要になるので追加します。

$ sudo yum install epel-release

注:RHEL 7の場合は epelパッケージをダウンロードしてインストールします。

また、後述するphpおよびMariaDBのインストールでは、ol7_addons収録のoniguruma-5.9.5 を使用します。epel収録のoniguruma-6.8.2では依存関係解決でエラーとなりますので、epel収録のonigurumaを使用しないよう設定します。

設定は /etc/yum.repos.d/epel.repo の[epel]に対して「exclude=oniguruma」という記述を追加します。

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&amp;arch=$basearch&amp;infra=$infra&amp;content=$contentdir
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
exclude=oniguruma

インターネット公開用準備

インターネット公開にあたりやっておいた方が良いことです。

fail2ban導入

公開サーバには各種アタックが頻繁にやってきます。管理用sshポートにも行われ無駄にCPU資源とトラフィックを食われます。

多少なりとも低減した方がいいので、fail2banというEPELレポジトリに含まれるソフトウェアを導入します。

fail2banは、ログイン失敗ログなどを監視し、一定数を超えたら該当するIPアドレスからのアクセスを一定期間受け付けなくする仕組みです。

$  sudo yum install fail2ban

fail2banの設定は /etc/fail2ban/ にあり、fail2ban.confやjail.confなどがあります。

しかし、ユーザ側で設定を追加修正したい場合はこれらのファイルを直接編集するのではなく、 /etc/fail2ban/jail.local というファイルを作成してそこに行っていきます。

$ sudo vi /etc/fail2ban/jail.local

/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 <既知>の固定IPがあれば追加>

[sshd]
enabled = true
banaction = firewallcmd-ipset

bantime/findtimeは2種類書いてありますが、まずは24時間で設定して、管理アクセス等に問題がないことを確認したら3日に変更するなどしてください。

設定が終わったらfail2banサービスを起動するための設定を入れていきます。

まず、初期状態は起動しない設定であるためenableに変更します。

$ systemctl list-unit-files|grep fail
fail2ban.service                              disabled
$ sudo systemctl enable fail2ban.service
Created symlink from /etc/systemd/system/multi-user.target.wants/fail2ban.service to /usr/lib/systemd/system/fail2ban.service.
$ systemctl list-unit-files|grep fail
fail2ban.service                              enabled
$

次にfail2banを起動します。

$ systemctl status fail2ban.service
● fail2ban.service - Fail2Ban Service
   Loaded: loaded (/usr/lib/systemd/system/fail2ban.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:fail2ban(1)
$ sudo systemctl start fail2ban.service
$ systemctl status fail2ban.service
● fail2ban.service - Fail2Ban Service
   Loaded: loaded (/usr/lib/systemd/system/fail2ban.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-07-07 10:23:36 JST; 2s ago
     Docs: man:fail2ban(1)
  Process: 2099 ExecStartPre=/bin/mkdir -p /run/fail2ban (code=exited, status=0/SUCCESS)
 Main PID: 2100 (f2b/server)
   CGroup: /system.slice/fail2ban.service
           mq2100 /usr/bin/python -s /usr/bin/fail2ban-server -xf start

Jul 07 10:23:36 phoenix-websa-jp systemd[1]: Starting Fail2Ban Service...
Jul 07 10:23:36 phoenix-websa-jp systemd[1]: Started Fail2Ban Service.
Jul 07 10:23:37 phoenix-websa-jp fail2ban-server[2100]: Server ready

動作確認を行います。

わざとパスワードを間違えるなどして /var/log/fail2ban.log にログが出力されることを確認します。

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:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
$ 

httpとhttpsの公開設定を入れます。

$ sudo firewall-cmd --permanent --zone=public --add-service=http
success
$ sudo firewall-cmd --permanent --zone=public --add-service=https
success
$

reloadを行って設定を反映します。

$ 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:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
$

php 7.4追加編

Oralce Linux 7だと簡単に追加できたりするPHP Packages for Oracle Linuxを利用する。

/etc/yum.repos.d/oracle-php.repo というファイルを作って下記を記載する。(sudo vi /etc/yum.repos.d/oracle-php.repo )

[ol7_developer_php74]
name=Oracle Linux $releasever PHP 7.4 Packages for Development and test ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/developer/php74/$basearch/
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=0
enabled=1

[ol7_addons]
name=Oracle Linux $releasever Add ons ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/addons/$basearch/
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=0
enabled=1

上記では「ol7_developer_php74」と「ol7_addons」を追加しているが、ol7_addonsの方はMariaDBのインストール時にも必要になるレポジトリとなる。

phpをインストールします。あとでWordpressから要求されるパッケージもあるのでいろいろインストールします。(php-pecl-imagick と php-mbstring はパッケージの依存の問題でインストール不可だった )

$ sudo yum install php php-json php-bcmath php-pear-Net-Curl php-gd php-mbstring
<略>
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                 Arch   Version               Repository           Size
================================================================================
Installing:
 php                     x86_64 7.4.7-1.0.1.el7       ol7_developer_php74 3.4 M
 php-bcmath              x86_64 7.4.7-1.0.1.el7       ol7_developer_php74  56 k
 php-gd                  x86_64 7.4.7-1.0.1.el7       ol7_developer_php74  72 k
 php-json                x86_64 7.4.7-1.0.1.el7       ol7_developer_php74  58 k
 php-pear-Net-Curl       noarch 1.2.5-10.el7          epel                 13 k
 php-mbstring            x86_64 7.4.7-1.0.1.el7       ol7_developer_php74  500 k
Installing for dependencies:
 apr                     x86_64 1.4.8-5.el7           base                103 k
 apr-util                x86_64 1.5.2-6.el7           base                 92 k
 dejavu-fonts-common     noarch 2.33-6.el7            base                 64 k
 dejavu-sans-fonts       noarch 2.33-6.el7            base                1.4 M
 fontconfig              x86_64 2.13.0-4.3.el7        base                254 k
 fontpackages-filesystem noarch 1.44-8.el7            base                9.9 k
 gd-last                 x86_64 2.1.1-2.el7           ol7_developer_php74 140 k
 httpd                   x86_64 2.4.6-93.el7.centos   base                2.7 M
 httpd-tools             x86_64 2.4.6-93.el7.centos   base                 92 k
 jbigkit-libs            x86_64 2.0-11.el7            base                 46 k
 libX11                  x86_64 1.6.7-2.el7           base                607 k
 libX11-common           noarch 1.6.7-2.el7           base                164 k
 libXau                  x86_64 1.0.8-2.1.el7         base                 29 k
 libXpm                  x86_64 3.5.12-1.el7          base                 55 k
 libjpeg-turbo           x86_64 1.2.90-8.el7          base                135 k
 libtiff                 x86_64 4.0.3-32.el7          base                171 k
 libvpx                  x86_64 1.3.0-5.el7_0         base                498 k
 libxcb                  x86_64 1.13-1.el7            base                214 k
 libxslt                 x86_64 1.1.28-5.el7          base                242 k
 mailcap                 noarch 2.1.41-2.el7          base                 31 k
 php-cli                 x86_64 7.4.7-1.0.1.el7       ol7_developer_php74 5.1 M
 php-common              x86_64 7.4.7-1.0.1.el7       ol7_developer_php74 1.1 M
 php-pear                noarch 1:1.9.4-21.el7        base                357 k
 php-process             x86_64 7.4.7-1.0.1.el7       ol7_developer_php74  76 k
 php-xml                 x86_64 7.4.7-1.0.1.el7       ol7_developer_php74 185 k
 oniguruma               x86_64 5.9.5-3.el7           ol7_addons          128 k

Transaction Summary
================================================================================
Install  6 Packages (+26 Dependent packages)

Total download size: 17 M
Installed size: 68 M
Is this ok [y/d/N]: y
<略>
$

この操作によりWebサーバもインストールされている。

なお、php-mbstringのインストールで失敗する場合、epel収録のoniguruma 6がインストールされているか、oniguruma 5がレポジトリ内に見つからない、というものです。

oniguruma 5はol7_addonに含まれます。

MariaDB設定編

CentOS7ではmariadb 5.5.65が用意されている。しかし、このバージョンはWordPress推奨ではないため、最新版のMariaDBをMariaDB Foundationから入手しインストールする。

「/etc/yum.repos.d/mariadb.repo」というファイルを作り、以下の内容を入力。(sudo vi /etc/yum.repos.d/mariadb.repo)

# MariaDB 10.5 CentOS repository list - created 2020-07-07 02:24 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

そして、mariadb-serverをインストールします。

$ sudo yum install MariaDB-server MariaDB-client
<略>
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                    Arch      Version                  Repository  Size
================================================================================
Installing:
 MariaDB-client             x86_64    10.5.4-1.el7.centos      mariadb     13 M
 MariaDB-compat             x86_64    10.5.4-1.el7.centos      mariadb    2.2 M
     replacing  mariadb-libs.x86_64 1:5.5.65-1.el7
 MariaDB-server             x86_64    10.5.4-1.el7.centos      mariadb     26 M
Installing for dependencies:
 MariaDB-common             x86_64    10.5.4-1.el7.centos      mariadb     81 k
 boost-program-options      x86_64    1.53.0-28.el7            base       156 k
 galera-4                   x86_64    26.4.5-1.el7.centos      mariadb    9.5 M
 pcre2                      x86_64    10.23-2.el7              base       201 k
 perl-Compress-Raw-Bzip2    x86_64    2.061-3.el7              base        32 k
 perl-Compress-Raw-Zlib     x86_64    1:2.061-4.el7            base        57 k
 perl-DBI                   x86_64    1.627-4.el7              base       802 k
 perl-Data-Dumper           x86_64    2.145-3.el7              base        47 k
 perl-IO-Compress           noarch    2.061-2.el7              base       260 k
 perl-Net-Daemon            noarch    0.48-5.el7               base        51 k
 perl-PlRPC                 noarch    0.2020-14.el7            base        36 k
 socat                      x86_64    1.7.3.2-2.el7            base       290 k

Transaction Summary
================================================================================
Install  3 Packages (+12 Dependent packages)

Total download size: 52 M
Is this ok [y/d/N]: y
<略>
$

MariaDBサーバの自動起動を設定します。

$ systemctl list-unit-files|grep mariadb
mariadb.service                               disabled
mariadb@.service                              disabled
$ sudo systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
$ systemctl list-unit-files|grep mariadb
mariadb.service                               enabled
mariadb@.service                              disabled
$

MariaDBを起動します。

$ systemctl status mariadb.service
● mariadb.service - MariaDB 10.5.4 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           mqmigrated-from-my.cnf-settings.conf
   Active: inactive (dead)
     Docs: man:mariadbd(8)
           https://mariadb.com/kb/en/library/systemd/
$ sudo systemctl start mariadb.service
$ systemctl status mariadb.service
● mariadb.service - MariaDB 10.5.4 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           mqmigrated-from-my.cnf-settings.conf
   Active: active (running) since Tue 2020-07-07 11:30:10 JST; 1s ago
     Docs: man:mariadbd(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 32580 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 32554 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] &amp;&amp; VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   &amp;&amp; systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 32552 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 32565 (mariadbd)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           mq32565 /usr/sbin/mariadbd

Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: 2020-07-07 11:30:10 0 [Note...
Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: 2020-07-07 11:30:10 0 [Note...
Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: 2020-07-07 11:30:10 0 [Note...
Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: 2020-07-07 11:30:10 0 [Note...
Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: 2020-07-07 11:30:10 0 [Note...
Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: 2020-07-07 11:30:10 0 [Note...
Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: 2020-07-07 11:30:10 0 [Note...
Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: 2020-07-07 11:30:10 0 [Note...
Jul 07 11:30:10 phoenix-websa-jp mariadbd[32565]: Version: '10.5.4-MariaDB'  ...
Jul 07 11:30:10 phoenix-websa-jp systemd[1]: Started MariaDB 10.5.4 database....
Hint: Some lines were ellipsized, use -l to show in full.
$

最後にWordpress用データベースを作成します。

$ sudo mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.5.4-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database DB名 character set utf8;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> grant all on DB名.* to wordpress@localhost identified by 'パスワード';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> quit
Bye
$

Webサーバ SSL設定編

昨今のWebサーバはSSL化が必須です。

Let’s Encriptを利用したSSL化が使用しやすいですが、certbotだと仕組みが大がかりになってしまうので小回りが利くshellベースのdehydratedを使用します。

EPELレポジトリに含まれているため導入は簡単です。

$ sudo yum install dehydrated
<略>--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch            Version                Repository     Size
================================================================================
Installing:
 dehydrated          noarch          0.6.5-1.el7            epel           85 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 85 k
Installed size: 164 k
Is this ok [y/d/N]: y
<略>
$

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 )

Alias /.well-known/acme-challenge /var/www/dehydrated
&lt;Directory /var/www/dehydrated/>
&lt;/Directory>

Webサーバが自動起動するように設定します。

$ systemctl list-unit-files |grep http
httpd.service                                 disabled
$ sudo systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
$ systemctl list-unit-files |grep http
httpd.service                                 enabled
$

続いてWebサーバを起動します。

$ systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)
$ sudo systemctl start httpd.service
$ systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-07-07 10:55:23 JST; 14s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 30854 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           tq30854 /usr/sbin/httpd -DFOREGROUND
           tq30855 /usr/sbin/httpd -DFOREGROUND
           tq30856 /usr/sbin/httpd -DFOREGROUND
           tq30857 /usr/sbin/httpd -DFOREGROUND
           tq30858 /usr/sbin/httpd -DFOREGROUND
           mq30859 /usr/sbin/httpd -DFOREGROUND

Jul 07 10:55:22 phoenix-websa-jp systemd[1]: Starting The Apache HTTP Server...
Jul 07 10:55:23 phoenix-websa-jp systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
$

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

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

登録作業を開始します。

$ 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.2-November-15-2017.pdf

To accept these terms of service run `/bin/dehydrated --register --accept-terms`.
$
$ sudo 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 ID...
+ 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 phoenix.websa.jp
 + Creating new directory /etc/dehydrated/certs/phoenix.websa.jp ...
 + Signing domains...
 + Generating private key...
 + Generating signing request...
 + Requesting new certificate order from CA...
 + Received 1 authorizations URLs from the CA
 + Handling authorization for phoenix.websa.jp
 + 1 pending challenge(s)
 + Deploying challenge tokens...
 + Responding to challenge for phoenix.websa.jp authorization...
 + Challenge is valid!
 + Cleaning challenge tokens...
 + Requesting certificate...
 + Checking certificate...
 + Done!
 + Creating fullchain.pem...
 + Done!
$

/etc/dehydrated/certs/ にdomais.txtの各行の一番最初に書いたホスト名のディレクトリが作られており、その中に証明書が配置されています。

$ sudo ls -l /etc/dehydrated/certs/
total 0
drwx------. 2 root root 239 Jul  7 11:04 phoenix.websa.jp
$ sudo ls -l /etc/dehydrated/certs/phoenix.websa.jp/
total 20
-rw-------. 1 root root 1655 Jul  7 11:04 cert-1594087457.csr
-rw-------. 1 root root 2256 Jul  7 11:04 cert-1594087457.pem
lrwxrwxrwx. 1 root root   19 Jul  7 11:04 cert.csr -> cert-1594087457.csr
lrwxrwxrwx. 1 root root   19 Jul  7 11:04 cert.pem -> cert-1594087457.pem
-rw-------. 1 root root 1648 Jul  7 11:04 chain-1594087457.pem
lrwxrwxrwx. 1 root root   20 Jul  7 11:04 chain.pem -> chain-1594087457.pem
-rw-------. 1 root root 3904 Jul  7 11:04 fullchain-1594087457.pem
lrwxrwxrwx. 1 root root   24 Jul  7 11:04 fullchain.pem -> fullchain-1594087457.pem
-rw-------. 1 root root 3243 Jul  7 11:04 privkey-1594087457.pem
lrwxrwxrwx. 1 root root   22 Jul  7 11:04 privkey.pem -> privkey-1594087457.pem
$

なお、Let’s EncryptのSSL証明書は有効期限90日ですが、 /etc/cron.d/dehydrated に更新処理が設定されています。

Apacheに対する設定変更

phpインストール時に導入されたのはhttpのみで、httpsアクセスに関連するモジュール(mod_ssl)はインストールされていません。

$ sudo yum install mod_ssl
<略>
$

mod_sslによりSSL設定ファイルが /etc/httpd/conf.d/ssl.conf に配置されます。

しかし今どきじゃないようなので、ApacheのSSL対応設定をMozilla SSL Configuration Generatorベースの設定をssl-mozilla.confとして記載します。

$ sudo vi /etc/httpd/conf.d/ssl-mozilla.conf 

記載する内容は下記の様になる。

# generated 2020-07-07, Mozilla Guideline v5.4, Apache 2.4.6, OpenSSL 1.0.2k, intermediate configuration, no OCSP
# https://ssl-config.mozilla.org/#server=apache&amp;version=2.4.6&amp;config=intermediate&amp;openssl=1.0.2k&amp;ocsp=false&amp;guideline=5.4

# this configuration requires mod_ssl, mod_rewrite, and mod_headers
&lt;VirtualHost *:80>
    RewriteEngine On
    RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
&lt;/VirtualHost>

&lt;VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile      /etc/dehydrated/certs/<ホスト名>/cert.pem
    SSLCertificateChainFile /etc/dehydrated/certs/<ホスト名>/chain.pem
    SSLCertificateKeyFile   /etc/dehydrated/certs/<ホスト名>/privkey.pem

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

# intermediate configuration
SSLProtocol             all -SSLv3 -TLSv1 -TLSv1.1
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
SSLHonorCipherOrder     off

変更後、Webサービスを再起動する。

$ sudo systemctl restart httpd
$

WordPress導入

EPELレポジトリにWordPressパッケージがありますがバージョンが5.1.6と古く、また、WordPress管理画面からのアップデートとのバッティング問題がありますので、パッケージは使用しません。

/var/www/htmlにwordpressのtar.gzを展開します。

$ cd /var/www/html
$ sudo wget https://wordpress.org/latest.tar.gz
$ ls
latest.tar.gz
$ sudo tar xfz latest.tar.gz
$ ls
latest.tar.gz  wordpress
$ sudo rm latest.tar.gz
$ ls -l
total 4
drwxr-xr-x. 5 nobody nfsnobody 4096 Jun 11 06:48 wordpress
$

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

$ ps -ef|grep http
root     32093     1  0 11:17 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   32094 32093  0 11:17 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   32095 32093  0 11:17 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   32096 32093  0 11:17 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   32097 32093  0 11:17 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   32098 32093  0 11:17 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   32103 32093  0 11:18 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   32113 32093  0 11:19 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
opc      32700  1911  0 11:38 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 Jun 11 06:48 wordpress
$

/var/www/html/wordpress をDocumentRootとするように ssl-mozilla.conf に追加する。

# generated 2020-07-07, Mozilla Guideline v5.4, Apache 2.4.6, OpenSSL 1.0.2k, intermediate configuration, no OCSP
# https://ssl-config.mozilla.org/#server=apache&amp;version=2.4.6&amp;config=intermediate&amp;openssl=1.0.2k&amp;ocsp=false&amp;guideline=5.4

# this configuration requires mod_ssl, mod_rewrite, and mod_headers
&lt;VirtualHost *:80>
    RewriteEngine On
    RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
&lt;/VirtualHost>

&lt;VirtualHost *:443>
    DocumentRoot /var/www/html/wordpress
    SSLEngine on
    SSLCertificateFile      /etc/dehydrated/certs/<ホスト名>/cert.pem
    SSLCertificateChainFile /etc/dehydrated/certs/<ホスト名>/chain.pem
    SSLCertificateKeyFile   /etc/dehydrated/certs/<ホスト名>/privkey.pem

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

# intermediate configuration
SSLProtocol             all -SSLv3 -TLSv1 -TLSv1.1
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
SSLHonorCipherOrder     off

設定後、Webサーバを再起動する

$ systemctl restart httpd
$

https://~/ にアクセスしてみると・・・

phpからmariadbにアクセスするためのパッケージが抜けていました。

$ sudo yum install php-mysql
<略>
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch       Version               Repository               Size
================================================================================
Installing:
 php-mysqlnd     x86_64     7.4.7-1.0.1.el7       ol7_developer_php74     228 k
Installing for dependencies:
 php-pdo         x86_64     7.4.7-1.0.1.el7       ol7_developer_php74     121 k

Transaction Summary
================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 349 k
Installed size: 1.2 M
Is this ok [y/d/N]: y
<略>
$

php関連のパッケージを変更した場合は、httpdを再起動します。

$ sudo systemctl restart httpd
$

無事にWordpress初期画面が確認出来ました。

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

$ sudo vi /var/www/html/wordpress/wp-config.php

以上で完了です。