2020年 05月 06日
SUSE Linux 15(openSUSE Leap 15)に mariadb、phpMyAdmin を入れるまで
ここでは SUSE Linux 15 (openSUSE Leap15.1) に nginx と mariadb をインストールして、phpMyAdmin を動かすまでの作業を説明します。この環境では openSUSE Leap 15.1 に nginx HTTP サーバーと php7 がインストールされています。事前の作業はこちらをまずご参考下さい。
SUSE15 で動かす nginx HTTP, インストールSUSE Linux 15(openSUSE15.1 Leap) で php7 on nginx
参考元となった文書はこちらです。大変分かりやすいので一緒に参考にしてください。
Install LEMP – Nginx, PHP, MariaDB and PhpMyAdmin in OpenSUSE
yast/yast2 で Software > Software Management から mariadb を "search" して、mariadb をチェックすると mariadb-client もインストールされます。あるいは zypper install します。 インストールが終わったら、yast/yast2 から > System > Service Manager を開き、mariadb を "Start" / "On Boot" にセットします。もしくは systemctrl コマンドを使います。 systemctrl でステータスを見るとこんな感じです。
opensuse151:~ # systemctl status mariadb● mariadb.service - MySQL serverLoaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2020-04-30 12:36:00 JST; 58s agoProcess: 9507 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper upgrade (code=exited, status=0/SUCC>Process: 9442 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper install (code=exited, status=0/SUCC>Main PID: 9513 (mysqld)Status: "Taking your SQL requests now..."Tasks: 30 (limit: 4915)CGroup: /system.slice/mariadb.service└─9513 /usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=mysqlApr 30 12:36:00 opensuse151 mysql-systemd-helper[9442]: rcmysql startApr 30 12:36:00 opensuse151 mysql-systemd-helper[9442]: You can test the MariaDB daemon with mariadb>Apr 30 12:36:00 opensuse151 mysql-systemd-helper[9442]: Please report any problems at http://mariadb>Apr 30 12:36:00 opensuse151 mysql-systemd-helper[9442]: The latest information about MariaDB is avai>Apr 30 12:36:00 opensuse151 mysql-systemd-helper[9442]: You can find additional information about th>Apr 30 12:36:00 opensuse151 mysql-systemd-helper[9442]: http://dev.mysql.comApr 30 12:36:00 opensuse151 mysql-systemd-helper[9442]: Consider joining MariaDB's strong and vibran>Apr 30 12:36:00 opensuse151 mysql-systemd-helper[9442]: https://mariadb.org/get-involved/Apr 30 12:36:00 opensuse151 mysql-systemd-helper[9513]: 2020-04-30 12:36:00 140479655942336 [Note] />Apr 30 12:36:00 opensuse151 systemd[1]: Started MySQL server.
mysql_secure_installation コマンドで、データベースの初期セットアップをします。
opensuse151:~ # mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none):
<--- パスワードは未セットなので[Enter]
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [Y/n] yNew password: <----- 新しい mysql の root パスワードRe-enter new password: <----- 新しい mysql の root パスワードPassword updated successfully!Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y <---- 後はデフォルトで Yes です。... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so farwill 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 MariaDBinstallation should now be secure.Thanks for using MariaDB!opensuse151:~ #
php-fpm の導入はこちらを参考にしてください。
SUSE Linux 15(openSUSE15.1 Leap) で php7 on nginxhttps://islandcnt.exblog.jp/240241791/
/etc/php7/fpm/php-fpm.conf ファイルのオリジナルのバックアップを取って、php-fpm.conf.default を上書きコピーしてから
error_log = log/php-fpm.log
の行のコメントを外して、有効化します。
opensuse151:~ # ls /etc/php7/fpm/php-fpm.conf php-fpm.conf.default php-fpm.dopensuse151:~ # cp /etc/php7/fpm/php-fpm.conf /etc/php7/fpm/php-fpm.conf.orgopensuse151:~ # cp /etc/php7/fpm/php-fpm.conf.default /etc/php7/fpm/php-fpm.confopensuse151:~ # ls /etc/php7/fpm/ -ltotal 24-rw-r--r-- 1 root root 4410 Apr 30 13:13 php-fpm.conf-rw-r--r-- 1 root root 4410 Mar 10 02:19 php-fpm.conf.default-rw-r--r-- 1 root root 4409 Apr 30 13:13 php-fpm.conf.orgdrwxr-xr-x 1 root root 48 Apr 11 14:00 php-fpm.dopensuse151:~ #opensuse151:~ # gedit /etc/php7/fpm/php-fpm.conf &
次の行を有効化します。
error_log = log/php-fpm.log
yast/yast2 から Software > Software Management より phpMyAdmin をサーチしてインストールします。もしくは zypper install します。別バージョンの openSUSE のパッケージの場合 software.opensuse.org の1クリックインストールが便利です。
/etc/nginx/vhosts.d/phpmyadmin.conf を次の様に作成します。これを作らないと mysql がライブラリエラーを吐きます。
opensuse151:~ # cat /etc/nginx/vhosts.d/phpmyadmin.confserver {listen 80;server_name localhost/phpMyAdmin;root /srv/www/htdocs/phpMyAdmin;location / {try_files $uri /index.php?$args;}location ~ \.php$ {try_files $uri =404;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;}}
systemctrl か yast の Service Manager から nginx と php-fpm を再起動します。
opensuse151:~ # systemctl restart nginxopensuse151:~ # systemctl restart php-fpm
ブラウザから、 phpMyAdmin の index.php を開きます。
http://host_ip/phpMyAdmin/index.php
root/ "mysql_secure_installation で設定したパスワード" でログインします。

無事に立ち上がりました。

Welcome to phpMyAdmin's documentation!
これで、SQLにくわしくなくても、MySQL のデータベースの管理ができます。