この間、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パッケージをダウンロードしてインストールします。
インターネット公開用準備
インターネット公開にあたりやっておいた方が良いことです。
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
phpをインストールします。あとでWordpressから要求されるパッケージもあるのでいろいろインストールします。(php-pecl-imagick と php-mbstring はパッケージの依存の問題でインストール不可だった )
$ sudo yum install php php-json php-bcmath php-pear-Net-Curl php-gd <略> --> 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 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 Transaction Summary ================================================================================ Install 5 Packages (+25 Dependent packages) Total download size: 17 M Installed size: 68 M Is this ok [y/d/N]: y <略> $
この操作によりWebサーバもインストールされている。
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 ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && 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 <Directory /var/www/dehydrated/> </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&version=2.4.6&config=intermediate&openssl=1.0.2k&ocsp=false&guideline=5.4 # this configuration requires mod_ssl, mod_rewrite, and mod_headers <VirtualHost *:80> RewriteEngine On RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L] </VirtualHost> <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" </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&version=2.4.6&config=intermediate&openssl=1.0.2k&ocsp=false&guideline=5.4 # this configuration requires mod_ssl, mod_rewrite, and mod_headers <VirtualHost *:80> RewriteEngine On RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L] </VirtualHost> <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" </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
以上で完了です。