openSUSE16.1 : MariaDB , WordPressインストール

1. MariaDB

1.1 インストール

①サーバーのパッケージを更新

# zypper ref
# zypper up -y

➁インストール

# zypper -n install mariadb

➂初期設定

# vi /etc/my.cnf

12行目 追記
[mysqld]
character-set-server=utf8 

④インストールされているか確認

# rpm -qi mariadb
Name        : mariadb
Version     : 12.3.2
Release     : 160100.2.2
Architecture: x86_64
Install Date: Mon 16 Nov 2026 05:11:43 PM JST
Group       : Productivity/Databases/Servers
Size        : 138740287
License     : SUSE-GPL-2.0-with-FLOSS-exception
Signature   : RSA/SHA512, Sat 12 Sep 2026 07:30:34 AM JST, Key ID fec28eaf09d9ea69
Source RPM  : mariadb-12.3.2-160100.2.2.src.rpm
Build Date  : Thu 11 Jun 2026 02:26:23 AM JST
Build Host  : reproducible
Packager    : https://www.suse.com/
Vendor      : SUSE LLC <https://www.suse.com/>
VCS         : https://src.suse.de/pool/mariadb?trackingbranch=slfo-1.3#973cf086fb1ad9008962e96b2adfb579a96b76088bf784e55b3c7e8796836b31
URL         : https://www.mariadb.org
Summary     : Server part of MariaDB
Description :
MariaDB is an open-source, multi-threaded, relational database management
system. It's a backward compatible, drop-in replacement branch of the
MySQL Community Server.

This package only contains the server-side programs.
Distribution: SUSE Linux 16

⑤MariaDBサービスの起動と有効化

# systemctl start mariadb
# systemctl enable mariadb

サービスの状態を確認し、実際に稼働していることを確認する

# systemctl status mariadb
● mariadb.service - MariaDB database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled)
     Active: active (running) since Mon 2026-11-16 17:14:22 JST; 45s ago
 Invocation: 2104be411ae64d0db71ab7fc60e11cdc
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 14577 (mysqld)
     Status: "Taking your SQL requests now..."
      Tasks: 14 (limit: 2229)
        CPU: 1.638s
     CGroup: /system.slice/mariadb.service
             └─14577 /usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=mysql --socket=/run/mysql/mysql.sock

Nov 16 17:14:21 Lepard mysql-systemd-helper[14527]: you need to be the system 'mysql' user to connect.
Nov 16 17:14:21 Lepard mysql-systemd-helper[14527]: After connecting you can set the password, if you would need to be
Nov 16 17:14:21 Lepard mysql-systemd-helper[14527]: able to connect as any of these users with a password and without sudo
Nov 16 17:14:21 Lepard mysql-systemd-helper[14527]: See the MariaDB Knowledgebase at https://mariadb.com/kb
Nov 16 17:14:21 Lepard mysql-systemd-helper[14527]: Please report any problems at https://mariadb.org/jira
Nov 16 17:14:21 Lepard mysql-systemd-helper[14527]: The latest information about MariaDB is available at https://mariadb.org/.
Nov 16 17:14:21 Lepard mysql-systemd-helper[14527]: Consider joining MariaDB's strong and vibrant community:
Nov 16 17:14:21 Lepard mysql-systemd-helper[14527]: https://mariadb.org/get-involved/
Nov 16 17:14:21 Lepard mysql-systemd-helper[14577]: /usr/sbin/mysqld: Deprecated program name. It will be removed in a future release>
Nov 16 17:14:22 Lepard systemd[1]: Started MariaDB database server.

Active: active (running) サービスが稼働中であることを示します

⑥MariaDBのインストールのセキュリティー

MariaDBサーバーのrootユーザーのパスワードを変更しておきます。

# mysql_secure_installation

/usr/bin/mysql_secure_installation: Deprecated program name. It will be removed in a future release, use 'mariadb-secure-installation' instead

NOTE: MariaDB is secure by default. Running this script is mostly
      unecessary and it will likely be removed in a future release,
      but it is for now preserved for backwards compatibility.

Enter root user password or leave blank:

Enter current password for root (enter for none): [enter]
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y
Enabled successfully (or at least no errors was emitted)!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y
New password: [Password]
Re-enter new password: [Password]
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] Y
Query OK, 2 rows affected
SQL executed without errors!

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? [Y/n] Y
Query OK, 0 rows affected
SQL executed without errors!

By default, MariaDB 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? [Y/n] Y
 - Dropping test database...
Query OK, 0 rows affected
SQL executed without errors!
 - Removing privileges on test database...
Query OK, 2 rows affected
SQL executed without errors!

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

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

⑥MariaDBのバージョン確認

# mariadb -V
mariadb from 12.3.2-MariaDB, client 15.2 for Linux (x86_64) using  EditLine wrapper

⑦Firewalld を有効にしている 且つ リモートから MariaDB を利用する場合はサービスの許可

# firewall-cmd --add-service=mysql --permanent
# firewall-cmd --reload

2. phpMyAdmin インストール

phpMyAdmin をインストールして、Web ブラウザ経由で MariaDB の操作ができるように設定
①インストール

# zypper install phpMyAdmin phpMyAdmin-apache apache2-mod_php8

②設定ファイル編集

 # vi /etc/sysconfig/apache2

130行目 : 追記
 APACHE_MPM="prefork"

③Apache再起動

# systemctl restart apache2

④ブラウザで http://<IPアドレス>/phpMyAdmin にアクセスする
下記のログイン画面が表示されるので
Username : root
Password:   MariaDBのセキュリティーインストールで設定したrootユーザーのパスワード
Go クリック

下記phpMyAdminの設定画面が表示される

1.3 MariaDB データベース+ユーザー作成例

次にインストールするwordpress用ユーザー、パスワード、データベースを作成してみる
データベース :  wp_db
ユーザー : wp_user
パスワード : ?WHxx333Yo

# mysql -u root -p

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 27
Server version: 12.3.2-MariaDB MariaDB package

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 wp_db;
Query OK, 1 row affected (0.015 sec)

MariaDB [(none)]>  create user 'wp_user'@'localhost' identified by '?WHxx333Yo';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all on wp_db.* to 'wp_user'@'localhost';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>  flush privileges;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> exit;
Bye

2. WordPress

2.1 必要なライブラリーインストール
# zypper -n install php-gd php-pdo php-mysql php-mbstring php-simplexml php-curl apache2-mod_php8
2.2 WordPressダウンロードとインストール
# cd /srv/www/htdocs/[FQDN]
# wget http://ja.wordpress.org/latest-ja.tar.gz
# tar zxvf latest-ja.tar.gz
2.3 設定ファイルの編集
# cd wordpress/
# cp wp-config-sample.php wp-config.php

wordpress設定ファイルにデータベース設定

# vi wp-config.php

/** The name of the database for WordPress */
define( 'DB_NAME', 'wp_db' );  ←データベース名

/** Database username */
define( 'DB_USER', 'wp_user' );  ←ユーザー名

/** Database password */
define( 'DB_PASSWORD', '?WHxx333Yo' );  ←パスワード

/** Database hostname */

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

/srv/www/htdocs/[FQDN]の下に展開した中身を移動します

# cd /srv/www/htdocs/[FQDN]
# mv wordpress/* .

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

# rm -Rf wordpress
# rm -f latest-ja.tar.gz

wordpressディレクトリの所有者をapacheにします。
これをしないとプラグインのインストールなどの際に、ディレクトリを作成できないとか言われてしまします。

# chown -R wwwrun:wwwrun /srv/www/htdocs/[FQDN]
# chmod 775 -R /srv/www/htdocs/[FQDN]
# systemctl restart apache2
2.4 起動確認

ブラウザで http://[FQDN]/wp-admin/install.php に接続し、ユーザー名、パスワード等必要事項を入力し、インストールを開始してください
通常は、これで下図のWordpress管理画面にアクセスする「ユーザー名」「パスワード」等初期設定インストール画面が表示されますので
Site Title : 任意のタイトル
Username : 任意のユーザー名
Password : 任意のパスワード
Your Email : 管理者のメールアドレス
を入力し、「WordPressをインストール」クリック

WordPress管理画面への「ユーザー名またはメールアドレス」「パスワード」の入力画面が出ます。