業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

CentOS7.9 : MySQL8 , WordPressインストール

Mysql8 インストール

1.事前準備と確認

MariaDBがすでにインストールされていたら削除

# yum list installed | grep mariadb
mariadb-libs.x86_64                   1:5.5.68-1.el7                 @anaconda

MariaDBの停止・削除

# systemctl stop mariadb.service
# yum remove mariadb-*
# rm -rf /var/lib/mysql/

2.MySQL8インストール

MySQL公式リポジトリの追加

# yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

MySQLインストール

# yum --enablerepo=mysql80-community install mysql-community-server

バージョンを確認

# mysqld --version
/usr/sbin/mysqld Ver 8.0.32 for Linux on x86_64 (MySQL Community Server - GPL)

MySQLを起動・自動起動の設定

# systemctl start mysqld.service
# systemctl enable mysqld.service

デフォルトパスワードの確認・保存
次の「mysql_secure_installation」で初期設定する際必要です

# grep password /var/log/mysqld.log
2023-02-18T01:26:26.281528Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: xxxxxxxxx ← このパスワードを忘れずにメモしておく 

MySQL初期設定
「mysql_secure_installation」 コマンドを使用してrootユーザーのパスワードを設定し、いくつかの基本的なポリシーを設定します

# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:******** 上記で保存したデフォルトパスワード

The existing password for the user account root has expired. Please set a new password.

New password:xxxxxxxx  新しく設定するパスワード
Re-enter new password:xxxxxxxx  同上パスワード
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:xxxxxxxx 新しく設定したパスワード
Re-enter new password:xxxxxxxx 同上パスワード

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
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

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

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

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
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
-Dropping test database…
Success.

-Removing privileges on test database…
Success.

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
Success.

All done!

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

#vi /etc/my.cnf.d/charset.cnf

[mysqld]
character-set-server = utf8mb4
[client]
default-character-set = utf8mb4

WordPressインストール

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

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

2.Wordpressインストール

# cd /var/www/html/cent.korodes.com
# wget http://ja.wordpress.org/latest-ja.tar.gz
# tar xvf latest-ja.tar.gz

3.Wordpress設定ファイルの編集

# cd wordpress/
# cp wp-config-sample.php wp-config.php
# vi wp-config.php
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wp_db' );

/** Database username */
define( 'DB_USER', 'wp_user' );

/** Database password */
define( 'DB_PASSWORD', '?Ww123456' );

また、最終行に以下の分を追加します。
これをしないと、プラグインを追加するときにFTP接続情報なるものを聞かれます。
define('FS_METHOD', 'direct');

4.ファイルの移動

①/var/www/html/[wordpress用ドメイン名]の下に展開した中身を移動

# cd /var/www/html/cent.korodes.com
# mv wordpress/* .

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

# cd /var/www/html/alma.korodes.com
# rm -R -f wordpress
# rm latest-ja.tar.gz
wordpressディレクトリの所有者をapacheにします。
# chown -R apache:apache /var/www/html/cent.korodes.com

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

ブラウザでhttp://cent.korodes.com/wp-admin/install.phpにアクセスし、ユーザー名、パスワード等必要事項を入力し、インストールを開始してください

「お使いのサーバーの PHP では WordPress に必要な MySQL 拡張を利用できないようです。」表示されたら 次をインストールしてapacheとmysqlを再起動する

# yum install php-mysqlnd
# systemctl restart mysqld
# systemctl restart httpd
 
タイトルとURLをコピーしました