CentOS 8 インストール [08]

By | 2019年12月9日

さあ、今夜も頭蓋骨内に蟹味噌を製造するゾーっ!

5-1. php-fpmの起動と起動後の確認

# systemctl start php-fpm
# systemctl status php-fpm
php-fpm.service – The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor pr>
Active: active (running) since Mon 2019-12-09 17:22:15 JST; 2min 12s ago
Main PID: 839 (php-fpm)
Status: “Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/s>
Tasks: 3 (limit: 26213)
Memory: 25.1M
CGroup: /system.slice/php-fpm.service
tq 839 php-fpm: master process (/etc/php-fpm.conf)
tq1137 php-fpm: pool www
mq1138 php-fpm: pool www

12月 09 17:22:13 localhost.localdomain systemd[1]: Starting The PHP FastCGI Pro>
12月 09 17:22:15 localhost.localdomain php-fpm[839]: [09-Dec-2019 17:22:15] WAR>
12月 09 17:22:15 localhost.localdomain php-fpm[839]: [09-Dec-2019 17:22:15] WAR>
12月 09 17:22:15 localhost.localdomain systemd[1]: Started The PHP FastCGI Proc>
lines 1-16/16 (END)


5-2. php-fpmの自動起動設定

# systemctl enable php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.

# systemctl is-enabled php-fpm
enabled

6-1. php.iniの変更

# cp -p /etc/php.ini /etc/php.ini.org
# vi /etc/php.ini

6-1-1. PHPのセキュリティ設定

expose_php = Off      (PHPのバージョンを非表示)

6-1-2. アップロードサイズの変更

post_max_size = 20M

upload_max_filesize = 20M

6-1-3. タイムゾーンの設定

date.timezone = “Asia/Tokyo” (コメントアウトを外して追記)

6-1-4. マルチバイト対応(日本語対応)設定

mbstring.language = Japanese (コメントアウトを外した)

mbstring.internal_encoding = UTF-8 (コメントアウトを外して追記)

mbstring.http_input = UTF-8 (コメントアウトを外して追記)

mbstring.http_output = pass (コメントアウトを外して追記)

mbstring.encoding_translation = On (コメントアウトを外して変更)

mbstring.detect_order = auto (コメントアウトを外した)

mbstring.substitute_character = none (コメントアウトを外した)

7. php.ini設定ファイルの反映とhttpdの確認

# systemctl restart php-fpm
# systemctl status php-fpm
php-fpm.service – The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor pre>
Active: active (running) since Mon 2019-12-09 18:05:56 JST; 13s ago
Main PID: 2014 (php-fpm)
Status: “Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/s>
Tasks: 3 (limit: 26213)
Memory: 12.5M
CGroup: /system.slice/php-fpm.service
tq2014 php-fpm: master process (/etc/php-fpm.conf)
tq2017 php-fpm: pool www
mq2018 php-fpm: pool www

12月 09 18:05:56 localhost.localdomain systemd[1]: Starting The PHP FastCGI Pro>
12月 09 18:05:56 localhost.localdomain php-fpm[2014]: [09-Dec-2019 18:05:56] WA>
12月 09 18:05:56 localhost.localdomain php-fpm[2014]: [09-Dec-2019 18:05:56] WA>
12月 09 18:05:56 localhost.localdomain systemd[1]: Started The PHP FastCGI Proc>
lines 1-16/16 (END)

 

# systemctl restart httpd
[root@localhost ~]# systemctl status httpd
httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>
Drop-In: /usr/lib/systemd/system/httpd.service.d
mqphp-fpm.conf
Active: active (running) since Mon 2019-12-09 18:10:21 JST; 11s ago
Docs: man:httpd.service(8)
Main PID: 2029 (httpd)
Status: “Running, listening on: port 80”
Tasks: 213 (limit: 26213)
Memory: 51.3M
CGroup: /system.slice/httpd.service
tq2029 /usr/sbin/httpd -DFOREGROUND
tq2031 /usr/sbin/httpd -DFOREGROUND
tq2032 /usr/sbin/httpd -DFOREGROUND
tq2033 /usr/sbin/httpd -DFOREGROUND
mq2034 /usr/sbin/httpd -DFOREGROUND

12月 09 18:10:21 localhost.localdomain systemd[1]: Starting The Apache HTTP Ser>
12月 09 18:10:21 localhost.localdomain httpd[2029]: Server configured, listenin>
12月 09 18:10:21 localhost.localdomain systemd[1]: Started The Apache HTTP Serv>
lines 1-20/20 (END)

8. 動作確認

見事に動作しているのでしょう。

今夜は、盛りだくさん!続いて

CentOS 8にMySQL互換のデータベース MariaDB 10をインストールする

今回も、参考というよりも丸写しすると思われるページは、ここ


3-2. MariaDBのインストール

# dnf install -y mariadb-server mariadb mariadb-devel

自動的にインストールされて、「完了しました!」と表示されたら、

# dnf list installed | grep mariadb
mariadb.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream
mariadb-backup.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream
mariadb-common.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream
mariadb-connector-c.x86_64 3.0.7-1.el8 @AppStream
mariadb-connector-c-config.noarch 3.0.7-1.el8 @AppStream
mariadb-connector-c-devel.x86_64 3.0.7-1.el8 @AppStream
mariadb-devel.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream
mariadb-errmsg.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream
mariadb-gssapi-server.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream
mariadb-server.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream
mariadb-server-utils.x86_64 3:10.3.11-2.module_el8.0.0+35+6f2527ed @AppStream

3-4. MariaDB起動の確認

# systemctl start mariadb
# systemctl status mariadb
mariadb.service – MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor pr>
mariadb.service – MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor pr>
mariadb.service – MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor pr>
mariadb.service – MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor pr>
Active: active (running) since Mon 2019-12-09 18:40:22 JST; 14s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 6605 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, st>
Process: 6471 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service >
Process: 6446 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, stat>
Main PID: 6574 (mysqld)
Status: “Taking your SQL requests now…”
Tasks: 30 (limit: 26213)
Memory: 86.3M
CGroup: /system.slice/mariadb.service
mq6574 /usr/libexec/mysqld –basedir=/usr

12月 09 18:40:22 localhost.localdomain mysql-prepare-db-dir[6471]: Please report any problems at http://mariadb.org/jira
12月 09 18:40:22 localhost.localdomain mysql-prepare-db-dir[6471]: The latest information about MariaDB is available at http://mariadb.org/.
12月 09 18:40:22 localhost.localdomain mysql-prepare-db-dir[6471]: You can find additional information about the MySQL part at:
12月 09 18:40:22 localhost.localdomain mysql-prepare-db-dir[6471]: http://dev.mysql.com
12月 09 18:40:22 localhost.localdomain mysql-prepare-db-dir[6471]: Consider joining MariaDB’s strong and vibrant community:
12月 09 18:40:22 localhost.localdomain mysql-prepare-db-dir[6471]: https://mariadb.org/get-involved/
12月 09 18:40:22 localhost.localdomain mysqld[6574]: 2019-12-09 18:40:22 0 [Note] /usr/libexec/mysqld (mysqld 10.3.11-MariaDB) starting as process 6574 …
12月 09 18:40:22 localhost.localdomain mysqld[6574]: 2019-12-09 18:40:22 0 [Warning] Could not increase number of max_open_files to more than 1024 (request: 4186)
12月 09 18:40:22 localhost.localdomain mysqld[6574]: 2019-12-09 18:40:22 0 [Warning] Changed limits: max_open_files: 1024 max_connections: 151 (was 151) table_cache: 421 (was 2000)
12月 09 18:40:22 localhost.localdomain systemd[1]: Started MariaDB 10.3 database server.
lines 1-25/25 (END)

 

3-5. MariaDB自動起動の設定

# systemctl enable mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

# systemctl is-enabled mariadb
enabled

4-1. mysql_secure_installationの実行

# 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
you 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):
OK, successfully used password, moving on…

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

Set root password? [Y/n] y
New password:
Re-enter new 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
… 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!

5-1. server.cnfの変更

# cp -p /etc/my.cnf.d/mariadb-server.cnf /etc/my.cnf.d/mariadb-server.cnf.org
# vi /etc/my.cnf.d/mariadb-server.cnf

# this is read by the standalone daemon and embedded servers
[server]
character-set-server=utf8 (行を挿入して追記)

6. mariadb-server.cnf設定ファイルの反映とMariaDBの動作確認

# systemctl restart mariadb
# systemctl status mariadb
mariadb.service – MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2019-12-09 19:14:51 JST; 11s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 6821 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 6752 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0/>
Process: 6725 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 6790 (mysqld)
Status: “Taking your SQL requests now…”
Tasks: 30 (limit: 26213)
Memory: 74.7M
CGroup: /system.slice/mariadb.service
mq6790 /usr/libexec/mysqld –basedir=/usr

12月 09 19:14:50 localhost.localdomain systemd[1]: Starting MariaDB 10.3 database server…
12月 09 19:14:50 localhost.localdomain mysql-prepare-db-dir[6752]: Database MariaDB is probably initia>
12月 09 19:14:50 localhost.localdomain mysql-prepare-db-dir[6752]: If this is not the case, make sure >
12月 09 19:14:51 localhost.localdomain mysqld[6790]: 2019-12-09 19:14:51 0 [Note] /usr/libexec/mysqld >
12月 09 19:14:51 localhost.localdomain mysqld[6790]: 2019-12-09 19:14:51 0 [Warning] Could not increas>
12月 09 19:14:51 localhost.localdomain mysqld[6790]: 2019-12-09 19:14:51 0 [Warning] Changed limits: m>
12月 09 19:14:51 localhost.localdomain systemd[1]: Started MariaDB 10.3 database server.
lines 1-22/22 (END)

7. 動作確認

# mysql -uroot -p************************
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.11-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)]> create database test_db;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
| test_db |
+——————–+
4 rows in set (0.000 sec)

MariaDB [(none)]> use test_db;
Database changed
MariaDB [test_db]> show variables like “chara%”;
+————————–+——————————+
| Variable_name | Value |
+————————–+——————————+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mariadb/charsets/ |
+————————–+——————————+
8 rows in set (0.001 sec)

MariaDB [test_db]> drop database test_db;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
+——————–+
3 rows in set (0.000 sec)

MariaDB [(none)]> quit
Bye

動作確認は完了しました。以上で、基本的なLAMP環境が完成したので、

クローンを作成しておきます。

 

コメントを残す

メールアドレスが公開されることはありません。

日本語で書いてね。外国語わかんない。