LoginSignup
0
0

More than 1 year has passed since last update.

Clear LinuxにWordpressサーバを(その1)

Posted at

やりたいこと

定点カメラで撮影した映像をウェブページとしてきれいに見せたい。せっかくなので立ち上げたClearLinux上でWordpress上で表示してみよう!(Ubuntuではすでにやったこれおえはあるが、ClearLinuxでやることに意義がある!?)
ということで今回はちょっと長くなるので2回に分けます。遠いわけで今回はその1、phpMyAdminの設定まで。

ちなみに今のバージョンは

clear~ $ uname -a
Linux clear 5.16.5-1120.native #1 SMP Tue Feb 1 10:03:19 PST 2022 x86_64 GNU/Linux

LAMPサーバとしての立ち上げ

$ sudo swupd update
$ sudo systemctl enable httpd.service
$ sudo systemctl start httpd.service
$ sudo systemctl status httpd.service
$ sudo systemctl status httpd.service
パスワード: 
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor pre>
     Active: active (running) since Mon 2022-02-07 16:33:13 JST; 11min ago
   Main PID: 4177 (httpd)
     Status: "Processing requests..."
      Tasks: 157 (limit: 9250)
     Memory: 38.4M
     CGroup: /system.slice/httpd.service
             ├─4177 /usr/sbin/httpd -DFOREGROUND -k start
             ├─4182 /usr/sbin/httpd -DFOREGROUND -k start
             ├─4183 /usr/sbin/httpd -DFOREGROUND -k start
             └─4184 /usr/sbin/httpd -DFOREGROUND -k start

http://localhostで
It works!
と素っ気なく表示されればOK

CLではHTTPDのでフォールトの設定は
/usr/share/defaults/httpd.httpd.conf
として保存されているということですが、いつもの(?)
/etc/httpd/conf.d/
という場所に設定していきます。

$ cat httpd.conf 
#
# Set a new location for DocumentRoot
#
DocumentRoot "/var/www/html"

#
# Relax access to content within /var/www/html
#
<Directory "/var/www/html">
  AllowOverride none
  Require all granted
</Directory>

そして、MariaDB

clear~ $ sudo swupd bundle-add database-basic
パスワード: 
Loading required manifests...
Warning: Bundle "database-basic" is invalid, skipping it...
Failed to install 1 of 1 bundles

参照ページによるとdatabase-basicというバンドルがあるはずだが、見当たらないと。
なので、

clear~ $ sudo swupd bundle-add mariadb
Loading required manifests...
Downloading packs (95.92 MB) for:
 - mariadb
 [100%]

Finishing packs extraction...
Validate downloaded files
 [100%]

No extra files need to be downloaded
 [100%]

Installing files...
 [100%]

Calling post-update helper scripts
External command: pacrunner.service: restarted (the binary was updated)
External command: php-fpm.service: restarted (the binary was updated)
External command: httpd.service: restarted (the binary was updated)
Successfully installed 1 bundle
clear~ $ sudo systemctl status mariadb
○ mariadb.service - MariaDB database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor >
     Active: inactive (dead)
clear~ $ 
clear~ $ sudo systemctl enable --now  mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
clear~ $ sudo systemctl status mariadb
● mariadb.service - MariaDB database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor p>
     Active: active (running) since Mon 2022-02-07 17:49:25 JST; 2s ago
   Main PID: 6483 (mysqld)
      Tasks: 17 (limit: 9250)
     Memory: 65.4M
     CGroup: /system.slice/mariadb.service
             └─6483 /usr/bin/mysqld --pid-file=/run/mariadb/mariadb.pid


clear~ $ 
clear~ $ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
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] n
 ... skipping.

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

Change the root password? [Y/n] n
 ... skipping.

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
 ... 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? [Y/n] Y
 ... Success!

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...
 ... 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? [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 Version 10.6.5
PHP Version 8.1.2

phpMyAdminのインストール

まずphpMyAdminのファイルをダウンロード
https://www.phpmyadmin.net/downloads/
今回ダウンロードしたのはv5.1.2
ZIPファイルを展開して、CLのドキュメントルートに展開したDIRをそのままMV

sudo mv phpMyAdmin-5.1.2-all-languages /var/www/html/phpMyAdmin

ここでphpMyAdminのページにアクセスすると
http://localhost/phpMyAdmin
スクリーンショット 2022-02-07 21.03.03.png
Username : root
Password : (ここに何を入れてもだめ)
そういえばmysql_secure_installationでパスワードを聞かれたなと思い、パスワードを入れてもだめ、ユーザをUnixのユーザとパスワードをいれてもだめ・・・

・・・前出のスクリプトの切り出し・・・
You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
 ... skipping.

ここから先に行けないので困ってしまってググっていると、MariaDBのインストール時に同じような問題に当たった人がいるようで、ただ解決方法もいろいろありました。最終的に私はパスワードをSQLデータベースのUSERにセットして解決。

$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.6.5-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)]> SELECT user,password,plugin, authentication_string from mysql.user;
+-------------+----------+-----------------------+-----------------------+
| User        | Password | plugin                | authentication_string |
+-------------+----------+-----------------------+-----------------------+
| mariadb.sys |          | mysql_native_password |                       |
| root        |          | mysql_native_password |                       |
| mysql       | invalid  | mysql_native_password | invalid               |
+-------------+----------+-----------------------+-----------------------+
3 rows in set (0.011 sec)
MariaDB [(none)]> set password for root@localhost=password("YourPasswd");
Query OK, 0 rows affected (0.014 sec)

MariaDB [(none)]> SELECT user,password,plugin, authentication_string from mysql.user;
+-------------+-------------------------------------------+-----------------------+-------------------------------------------+
| User        | Password                                  | plugin                | authentication_string                     |
+-------------+-------------------------------------------+-----------------------+-------------------------------------------+
| mariadb.sys |                                           | mysql_native_password |                                           |
| root        | *5C5423970*********3362C1FCD5 | mysql_native_password | *5C5423970C9B************E13362C1FCD5 |
| mysql       | invalid                                   | mysql_native_password | invalid                                   |
+-------------+-------------------------------------------+-----------------------+-------------------------------------------+
3 rows in set (0.001 sec)
MariaDB [(none)]> commit;

これで無事解決
スクリーンショット 2022-02-07 21.24.59.png
この画面が出ればOK

次はWordPressをインストールするための準備

Databaseのタブをクリック
データベースの名前: WordPress
Collation: utf16_unicode_ci (参照リンクではutf9_unicode_ciとなっていたが相当するものが出てこなかったので、こちらを選択)
そしてCreateのボタンを押してデータベースを作成
そうすると左側のパネルにWordPressというデータベースができるので、そこをクリック
今度は右側の「権限」というタブをクリックすると下の方に「ユーザアカウントを追加する」というリンクが出てくるので、それをクリック。
スクリーンショット 2022-02-07 22.17.46.png
「ユーザアカウントを追加する」という画面で
ユーザ名:wordpressuser
ホスト:%
パスワード: wp-example
再入力:wp-example
以上を入力した上で

スクリーンショット 2022-02-07 21.35.57.png
「実行」ボタンを押す。

CLのProject Docにある記事はクオリティーが高いと思ってましたが、中級編のWordPressのインストールに近づいてくるにつれてだんだん、あれ、と思うことが多くなってきました。

参考リンク:
https://docs.01.org/clearlinux/latest/tutorials/lamp-server.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0