MiracleLinux ; データベース(Mysql) , WordPress

Mysql8 インストール

#dnf module -y install mysql:8.0
#vi /etc/my.cnf.d/charset.cnf

charset.cnf 下記の内容で新規作成

# デフォルトの文字コードを設定
# 絵文字等 4 バイト長の文字を扱う場合は [utf8mb4] [mysqld] character-set-server = utf8mb4
[client] default-character-set = utf8mb4
#systemctl enable –now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
完了したら、 「mysql_secure_installation」 コマンドを使用してrootユーザーのパスワードを設定し、いくつかの基本的なポリシーを設定します


Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

# パスワード品質チェックを有効にするか否か
Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

# パスワード品質チェックを有効にした場合は強度を選択
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 ←各自任意でよい
Please set the password for root here.

# MySQL root パスワードを設定
New password:  ← 任意のパスワード

Re-enter new password: ← 再度同じパスワード

# 入力したパスワードで良いかの確認
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production

# 匿名ユーザーを削除するか否か
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Normally, root should only be allowed to connect from
‘localhost’. This ensures that someone cannot guess at
the root password from the network.

# root ユーザーのリモートログインを無効とするか否か
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

By default, MySQL comes with a database named ‘test’ that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production

# テストデータベースを削除するか否か
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
– Dropping test database…

– Removing privileges on test database…

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

# 特権情報をリロードするか否か
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done!


1. Word Press 用のデータベースを作成

例としてデータベース[wp_db] データベースユーザー[wp_user] パスワード[?W123456]とします

# mysql -u root -p

Enter password: ←MySQL 用root パスワード入力します(画面上は表示されません)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24 Source distribution
Copyright (c) 2000, 2018, 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
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement

mysql> CREATE DATABASE wp_db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
| Database |
| information_schema |
| mysql |
| performance_schema |
| sys
| wp_db |
5 rows in set (0.00 sec)

mysql>CREATE USER ‘wp_user‘@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘?W123456‘;
Query OK, 0 rows affected (0.04 sec)

mysql> GRANT ALL ON wp_db.* TO ‘wp_user‘@’localhost’;
Query OK, 0 rows affected (0.04 sec)

mysql> flush privileges;

mysql> exit;

2 wordpress用Web サーバー設定

① Apache設定ファイル編集

# vi /usr/local/apache2/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin <管理者メールアドレス>
DocumentRoot /var/www/html/[wordpress用ドメイン名]/
ServerName [wordpress用ドメイン名]
ErrorLog “| /usr/local/apache2/bin/rotatelogs /var/log/httpd/[wordpress用ドメイン名] _error_log_%Y%m%d 86400540″
CustomLog “| /usr/local/apache2/bin/rotatelogs /var/log/httpd/[wordpress用ドメイン名] _access_log_%Y%m%d 86400 540″ combined
ErrorDocument 404 /
<Directory “/var/www/html/[wordpress用ドメイン名]“>
Options Indexes Includes FollowSymLinks MultiViews ExecCGI
Require all granted
Allow from all
AddHandler server-parsed .html
# systemctl restart httpd.service


# mkdir /var/www/html/[wordpress用ドメイン名]
# cd /var/www/html/[wordpress用ドメイン名]
# wget http://ja.wordpress.org/latest-ja.tar.gz
# tar xvf latest-ja.tar.gz


# cd wordpress/
# cp wp-config-sample.php wp-config.php
# vi wp-config.php
// ** MySQL 設定 – この情報はホスティング先から入手してください。 ** //
/** WordPress のためのデータベース名 */
define(‘DB_NAME’, ‘wp_db‘);

/** MySQL データベースのユーザー名 */
define(‘DB_USER’, ‘wp_user‘);

/** MySQL データベースのパスワード */
define(‘DB_PASSWORD’, ‘?W123456‘);

define(‘FS_METHOD’, ‘direct’);



# cd /var/www/html/[wordpress用ドメイン名]
# mv wordpress/* .

移動されたことを確認後 wordpressディレクトリーとダウンロードしたlatest-ja.tar.gzを削除

# cd /var/www/html/[wordpress用ドメイン名]
# rm -R -f wordpress
# rm latest-ja.tar.gz
# chown -R daemon:daemon /var/www/html/[wordpress用ドメイン名]

6.wordpress インストールの開始