CentOS 8 インストール [07]

By | 2019年12月9日

今夜も、このページを参考にしながら、PHP をインストールします。

CentOS と Apache httpd のバージョンを確認します。

# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
# httpd -V | head -n 1
Server version: Apache/2.4.37 (centos)

3-1. PHPパッケージの情報確認

# dnf info php php-mbstring php-xml php-xmlrpc php-gd php-pdo php-mysqlnd
メタデータの期限切れの最終確認: 0:06:55 時間前の 2019年12月08日 20時45分19秒 に 実施しました。
利用可能なパッケージ
名前 : php
バージョン : 7.2.11
リリース : 1.module_el8.0.0+56+d1ca79aa
アーキテクチ : x86_64
サイズ : 1.5 M
ソース : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.src.rpm
Repo : AppStream
概要 : PHP scripting language for creating dynamic web sites
URL : http://www.php.net/
ライセンス : PHP and Zend and BSD and MIT and ASL 1.0
説明 : PHP is an HTML-embedded scripting language. PHP attempts to make
: it easy for developers to write dynamically generated web pages.
: PHP also offers built-in database integration for several
: commercial and non-commercial database management systems, so
: writing a database-enabled webpage with PHP is fairly simple. The
: most common use of PHP coding is probably as a replacement for
: CGI scripts.
:
: The php package contains the module (often referred to as
: mod_php) which adds support for the PHP language to Apache HTTP
: Server.

名前 : php-gd
バージョン : 7.2.11
リリース : 1.module_el8.0.0+56+d1ca79aa
アーキテクチ : x86_64
サイズ : 83 k
ソース : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.src.rpm
Repo : AppStream
概要 : A module for PHP applications for using the gd graphics library
URL : http://www.php.net/
ライセンス : PHP
説明 : The php-gd package contains a dynamic shared object that will add
: support for using the gd graphics library to PHP.

名前 : php-mbstring
バージョン : 7.2.11
リリース : 1.module_el8.0.0+56+d1ca79aa
アーキテクチ : x86_64
サイズ : 580 k
ソース : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.src.rpm
Repo : AppStream
概要 : A module for PHP applications which need multi-byte string
: handling
URL : http://www.php.net/
ライセンス : PHP and LGPLv2 and OpenLDAP
説明 : The php-mbstring package contains a dynamic shared object that
: will add support for multi-byte string handling to PHP.

名前 : php-mysqlnd
バージョン : 7.2.11
リリース : 1.module_el8.0.0+56+d1ca79aa
アーキテクチ : x86_64
サイズ : 190 k
ソース : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.src.rpm
Repo : AppStream
概要 : A module for PHP applications that use MySQL databases
URL : http://www.php.net/
ライセンス : PHP
説明 : The php-mysqlnd package contains a dynamic shared object that
: will add MySQL database support to PHP. MySQL is an
: object-relational database management system. PHP is an
: HTML-embeddable scripting language. If you need MySQL support for
: PHP applications, you will need to install this package and the
: php package.
:
: This package use the MySQL Native Driver

名前 : php-pdo
バージョン : 7.2.11
リリース : 1.module_el8.0.0+56+d1ca79aa
アーキテクチ : x86_64
サイズ : 122 k
ソース : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.src.rpm
Repo : AppStream
概要 : A database access abstraction module for PHP applications
URL : http://www.php.net/
ライセンス : PHP
説明 : The php-pdo package contains a dynamic shared object that will
: add a database access abstraction layer to PHP. This module
: provides a common interface for accessing MySQL, PostgreSQL or
: other databases.

名前 : php-xml
バージョン : 7.2.11
リリース : 1.module_el8.0.0+56+d1ca79aa
アーキテクチ : x86_64
サイズ : 188 k
ソース : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.src.rpm
Repo : AppStream
概要 : A module for PHP applications which use XML
URL : http://www.php.net/
ライセンス : PHP
説明 : The php-xml package contains dynamic shared objects which add
: support to PHP for manipulating XML documents using the DOM tree,
: and performing XSL transformations on XML documents.

名前 : php-xmlrpc
バージョン : 7.2.11
リリース : 1.module_el8.0.0+56+d1ca79aa
アーキテクチ : x86_64
サイズ : 89 k
ソース : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.src.rpm
Repo : AppStream
概要 : A module for PHP applications which use the XML-RPC protocol
URL : http://www.php.net/
ライセンス : PHP and BSD
説明 : The php-xmlrpc package contains a dynamic shared object that will
: add support for the XML-RPC protocol to PHP.

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

# dnf install -y php php-mbstring php-xml php-xmlrpc php-gd php-pdo php-mysqlnd
メタデータの期限切れの最終確認: 0:12:55 時間前の 2019年12月08日 20時45分19秒 に 実施しました。
依存関係が解決しました。
================================================================================
パッケージ アーキテクチャー
バージョン リポジトリ
サイズ
================================================================================
Installing:
php x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 1.5 M
php-gd x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 83 k
php-mbstring x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 580 k
php-mysqlnd x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 190 k
php-pdo x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 122 k
php-xml x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 188 k
php-xmlrpc x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 89 k
依存関係をインストール中:
nginx-filesystem noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream 24 k
php-cli x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 3.1 M
php-common x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 653 k
弱い依存関係をインストール中:
php-fpm x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa AppStream 1.6 M
Enabling module streams:
nginx 1.14
php 7.2

トランザクションの概要
================================================================================
インストール 11 パッケージ

ダウンロードサイズの合計: 8.1 M
インストール済みのサイズ: 29 M
パッケージのダウンロード中です:
(1/11): nginx-filesystem-1.14.1-9.module_el8.0. 21 kB/s | 24 kB 00:01
(2/11): php-common-7.2.11-1.module_el8.0.0+56+d 291 kB/s | 653 kB 00:02
(3/11): php-7.2.11-1.module_el8.0.0+56+d1ca79aa 186 kB/s | 1.5 MB 00:08
(4/11): php-gd-7.2.11-1.module_el8.0.0+56+d1ca7 75 kB/s | 83 kB 00:01
(5/11): php-mbstring-7.2.11-1.module_el8.0.0+56 155 kB/s | 580 kB 00:03
(6/11): php-fpm-7.2.11-1.module_el8.0.0+56+d1ca 159 kB/s | 1.6 MB 00:10
(7/11): php-pdo-7.2.11-1.module_el8.0.0+56+d1ca 147 kB/s | 122 kB 00:00
(8/11): php-mysqlnd-7.2.11-1.module_el8.0.0+56+ 138 kB/s | 190 kB 00:01
(9/11): php-xmlrpc-7.2.11-1.module_el8.0.0+56+d 172 kB/s | 89 kB 00:00
(10/11): php-xml-7.2.11-1.module_el8.0.0+56+d1c 208 kB/s | 188 kB 00:00
(11/11): php-cli-7.2.11-1.module_el8.0.0+56+d1c 198 kB/s | 3.1 MB 00:16
——————————————————————————–
合計 472 kB/s | 8.1 MB 00:17
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
準備 : 1/1
Installing : php-common-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86 1/11
Installing : php-cli-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 2/11
Installing : php-pdo-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 3/11
Installing : php-xml-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 4/11
scriptletの実行中: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34 5/11
Installing : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34 5/11
Installing : php-fpm-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 6/11
scriptletの実行中: php-fpm-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 6/11
Installing : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 7/11
Installing : php-xmlrpc-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86 8/11
Installing : php-mysqlnd-7.2.11-1.module_el8.0.0+56+d1ca79aa.x8 9/11
Installing : php-gd-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 10/11
Installing : php-mbstring-7.2.11-1.module_el8.0.0+56+d1ca79aa.x 11/11
scriptletの実行中: php-mbstring-7.2.11-1.module_el8.0.0+56+d1ca79aa.x 11/11
scriptletの実行中: php-fpm-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 11/11
検証 : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34 1/11
検証 : php-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 2/11
検証 : php-cli-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 3/11
検証 : php-common-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86 4/11
検証 : php-fpm-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 5/11
検証 : php-gd-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 6/11
検証 : php-mbstring-7.2.11-1.module_el8.0.0+56+d1ca79aa.x 7/11
検証 : php-mysqlnd-7.2.11-1.module_el8.0.0+56+d1ca79aa.x8 8/11
検証 : php-pdo-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 9/11
検証 : php-xml-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64 10/11
検証 : php-xmlrpc-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86 11/11

インストール済み:
php-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
php-gd-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
php-mbstring-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
php-mysqlnd-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
php-pdo-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
php-xml-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
php-xmlrpc-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
php-fpm-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
php-cli-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64
php-common-7.2.11-1.module_el8.0.0+56+d1ca79aa.x86_64

完了しました!

3-3. インストールされたPHPパッケージの確認

# dnf list installed | grep php
php.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-cli.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-common.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-fpm.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-gd.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-mbstring.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-mysqlnd.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-pdo.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-xml.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream
php-xmlrpc.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream

3-4. php72 cliの動作確認

# php -v
PHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

4-1. インストールされたphp-fpmパッケージの確認

# dnf list installed | grep php-fpm
php-fpm.x86_64 7.2.11-1.module_el8.0.0+56+d1ca79aa @AppStream

4-2-1. php-fpm設定ファイルのバックアップ

# cp -p /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.org
# vi /etc/php-fpm.d/www.conf

4-3-1. php-fpmを動作させるユーザー、グループの設定変更

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user’s group
; will be used.
; RPM: apache user chosen to provide access to the same directories as httpd
user = dokolife_w
; RPM: Keep a group allowed to write in log dir.
group = dokolife_w

4-3-2. ソケット接続用の設定

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = dokolife_w
listen.group = dokolife_w
listen.mode = 0666
(3行ともコメントアウトを外す)

4-3-3. pm.max_パラメーターの変更

このあたりから、どのような設定にするか、悩ましいところです。

かなりの数のページを読みましたが、ハッキリ言ってよくわかりません。

私の CentOS8機の CPU は 2コアで、メモリは、8GB です。

CPU がボトルネックになるので、

pm.max_children = 2

としようと考えました。(コア数の2倍程度に設定するのがいいよという記事もありました)

pm = dynamic とした場合、各数値には以下のようなルールがあるとのことなので、

・pm.start_serversはpm.max_children,pm.max_spare_serversを超えてはならない
・pm.min_spare_serversはpm.max_children,pm.start_servers,pm.max_spare_serversを超えてはならない
・pm.max_spare_serversはpm.max_childrenを超えてはならない

すべて、2以下の数値でなければならないことになります。

意味ないじゃん?

だから、pm = static 決定!

しかし、その場合、設定不要となる pm.start_servers 、

pm.min_spare_servers 、pm.max_spare_servers を

コメントアウトしておけと書いてるページが見つからなかったんだよね。

こういうとき、基本的な知識に欠けてると大いに悩むことに

なるんですが、今回は、コメントアウトしてみました。

; Choose how the process manager will control the number of child processes.
; Possible Values:
; static – a fixed number (pm.max_children) of child processes;
; dynamic – the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children – the maximum number of children that can
; be alive at the same time.
; pm.start_servers – the number of children created on startup.
; pm.min_spare_servers – the minimum number of children in ‘idle’
; state (waiting to process). If the number
; of ‘idle’ processes is less than this
; number then some children will be created.
; pm.max_spare_servers – the maximum number of children in ‘idle’
; state (waiting to process). If the number
; of ‘idle’ processes is greater than this
; number then some children will be killed.
; ondemand – no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children – the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout – The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = static

; The number of child processes to be created when pm is set to ‘static’ and the
; maximum number of child processes when pm is set to ‘dynamic’ or ‘ondemand’.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don’t
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to ‘static’, ‘dynamic’ or ‘ondemand’
; Note: This value is mandatory.
pm.max_children = 2

; The number of child processes created on startup.
; Note: Used only when pm is set to ‘dynamic’
; Default Value: min_spare_servers + (max_spare_servers – min_spare_servers) / 2
; pm.start_servers = 5 (コメントアウト)

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to ‘dynamic’
; Note: Mandatory when pm is set to ‘dynamic’
; pm.min_spare_servers = 5 (コメントアウト)

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to ‘dynamic’
; Note: Mandatory when pm is set to ‘dynamic’
; pm.max_spare_servers = 35 (コメントアウト)

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to ‘ondemand’
; Default Value: 10s
;pm.process_idle_timeout = 10s;

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify ‘0’. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500 (コメントアウトを外した)

今夜は、ここまで。

明晩は、「5. php-fpmの起動と自動起動設定」以降に取り組みます。

コメントを残す

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

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