CentOS 7の環境でPHP 7.3・MariaDB 10.3をインストールする

2019年3月8日

先日のネタに突っ込みがありました。

う、確かに。

メンテナンスアップデートも2020年までと、うかうかしてられる状態ではないのは確か。
自前のサーバなので自己責任ではありますが、いい加減新しい環境に移るべきだろうということで、CentOS 7でこのブログか今日を作り直そうかと実験中です。

ひとまず、PHPとMariaDBをできるだけ新しめのものにしてみる。

今回も仮想環境を作って、ほぼ素の状態のCentOS 7の環境に対していろいろ試してみました。

MariaDB 10.3のインストール

標準ではバージョンが5.5なのですが、最新版は10系統になってるので、そちらをインストールしてみます。

[yuuichi@localhost ~]$ rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64

こちらの手順通りで、10.3をインストールできました。

[root@localhost yuuichi]# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
[info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo.
[info] Adding trusted package signing keys...
[info] Succeessfully added trusted package signing keys.
[root@localhost yuuichi]# systemctl stop mariadb
[root@localhost yuuichi]# yum update mariadb-server
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.jaist.ac.jp
 * epel: ftp.riken.jp
 * extras: ftp.jaist.ac.jp
 * remi-safe: ftp.riken.jp
 * updates: ftp.jaist.ac.jp
mariadb-main                                             | 2.9 kB     00:00
mariadb-maxscale                                         | 2.4 kB     00:00
mariadb-tools                                            | 2.9 kB     00:00
(1/3): mariadb-tools/7/x86_64/primary_db                   |  11 kB   00:01
(2/3): mariadb-maxscale/7/x86_64/primary_db                | 6.7 kB   00:01
(3/3): mariadb-main/7/x86_64/primary_db                    |  50 kB   00:01
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-server.x86_64 0:10.3.11-1.el7.centos を 非推奨
--> 依存性の処理をしています: galera のパッケージ: MariaDB-server-10.3.11-1.el7.centos.x86_64
--> 依存性の処理をしています: MariaDB-common のパッケージ: MariaDB-server-10.3.11-1.el7.centos.x86_64
--> 依存性の処理をしています: MariaDB-client のパッケージ: MariaDB-server-10.3.11-1.el7.centos.x86_64
---> パッケージ mariadb-server.x86_64 1:5.5.60-1.el7_5 を 不要
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-client.x86_64 0:10.3.11-1.el7.centos を 非推奨
---> パッケージ MariaDB-common.x86_64 0:10.3.11-1.el7.centos を インストール
--> 依存性の処理をしています: MariaDB-compat のパッケージ: MariaDB-common-10.3.11-1.el7.centos.x86_64
---> パッケージ galera.x86_64 0:25.3.24-1.rhel7.el7.centos を インストール
--> 依存性の処理をしています: libboost_program_options.so.1.53.0()(64bit) のパッケージ: galera-25.3.24-1.rhel7.el7.centos.x86_64
---> パッケージ mariadb.x86_64 1:5.5.60-1.el7_5 を 不要
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-compat.x86_64 0:10.3.11-1.el7.centos を 非推奨
---> パッケージ boost-program-options.x86_64 0:1.53.0-27.el7 を インストール
---> パッケージ mariadb-libs.x86_64 1:5.5.60-1.el7_5 を 不要
--> 依存性解決を終了しました。

依存性を解決しました

================================================================================
 Package                アーキテクチャー
                                バージョン                  リポジトリー   容量
================================================================================
インストール中:
 MariaDB-client         x86_64  10.3.11-1.el7.centos        mariadb-main   53 M
     mariadb.x86_64 1:5.5.60-1.el7_5 を入れ替えます
 MariaDB-compat         x86_64  10.3.11-1.el7.centos        mariadb-main  2.8 M
     mariadb-libs.x86_64 1:5.5.60-1.el7_5 を入れ替えます
 MariaDB-server         x86_64  10.3.11-1.el7.centos        mariadb-main  123 M
     mariadb-server.x86_64 1:5.5.60-1.el7_5 を入れ替えます
依存性関連でのインストールをします:
 MariaDB-common         x86_64  10.3.11-1.el7.centos        mariadb-main  157 k
 boost-program-options  x86_64  1.53.0-27.el7               base          156 k
 galera                 x86_64  25.3.24-1.rhel7.el7.centos  mariadb-main  8.1 M

トランザクションの要約
================================================================================
インストール  3 パッケージ (+3 個の依存関係のパッケージ)

総ダウンロード容量: 188 M
Is this ok [y/d/N]: y
Downloading packages:
(1/6): MariaDB-10.3.11-centos73-x86_64-common.rpm          | 157 kB   00:02
(2/6): MariaDB-10.3.11-centos73-x86_64-compat.rpm          | 2.8 MB   00:12
(3/6): boost-program-options-1.53.0-27.el7.x86_64.rpm      | 156 kB   00:00
(4/6): MariaDB-10.3.11-centos73-x86_64-client.rpm          |  53 MB   01:05
(5/6): galera-25.3.24-1.rhel7.el7.centos.x86_64.rpm        | 8.1 MB   00:19
(6/6): MariaDB-10.3.11-centos73-x86_64-server.rpm          | 123 MB   02:31
--------------------------------------------------------------------------------
合計                                               1.1 MB/s | 188 MB  02:46
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : MariaDB-compat-10.3.11-1.el7.centos.x86_64      1/9
  インストール中          : MariaDB-common-10.3.11-1.el7.centos.x86_64      2/9
warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
  インストール中          : MariaDB-client-10.3.11-1.el7.centos.x86_64      3/9
  インストール中          : boost-program-options-1.53.0-27.el7.x86_64      4/9
  インストール中          : galera-25.3.24-1.rhel7.el7.centos.x86_64        5/9
  インストール中          : MariaDB-server-10.3.11-1.el7.centos.x86_64      6/9
  削除中                  : 1:mariadb-server-5.5.60-1.el7_5.x86_64          7/9
warning: /var/log/mariadb/mariadb.log saved as /var/log/mariadb/mariadb.log.rpmsave
  削除中                  : 1:mariadb-5.5.60-1.el7_5.x86_64                 8/9
  削除中                  : 1:mariadb-libs-5.5.60-1.el7_5.x86_64            9/9
  検証中                  : MariaDB-common-10.3.11-1.el7.centos.x86_64      1/9
  検証中                  : MariaDB-client-10.3.11-1.el7.centos.x86_64      2/9
  検証中                  : galera-25.3.24-1.rhel7.el7.centos.x86_64        3/9
  検証中                  : MariaDB-compat-10.3.11-1.el7.centos.x86_64      4/9
  検証中                  : MariaDB-server-10.3.11-1.el7.centos.x86_64      5/9
  検証中                  : boost-program-options-1.53.0-27.el7.x86_64      6/9
  検証中                  : 1:mariadb-server-5.5.60-1.el7_5.x86_64          7/9
  検証中                  : 1:mariadb-libs-5.5.60-1.el7_5.x86_64            8/9
  検証中                  : 1:mariadb-5.5.60-1.el7_5.x86_64                 9/9

インストール:
  MariaDB-client.x86_64 0:10.3.11-1.el7.centos
  MariaDB-compat.x86_64 0:10.3.11-1.el7.centos
  MariaDB-server.x86_64 0:10.3.11-1.el7.centos

依存性関連をインストールしました:
  MariaDB-common.x86_64 0:10.3.11-1.el7.centos
  boost-program-options.x86_64 0:1.53.0-27.el7
  galera.x86_64 0:25.3.24-1.rhel7.el7.centos

置換:
  mariadb.x86_64 1:5.5.60-1.el7_5         mariadb-libs.x86_64 1:5.5.60-1.el7_5
  mariadb-server.x86_64 1:5.5.60-1.el7_5

完了しました!

特にハマるところもなくアップデート完了。その後は mysql_secure_installation コマンドを使って初期設定すれば使える状態になりますね。
環境に応じて、/etc/my.cnf は編集する感じで。

PHP 7.3のインストール

[root@localhost yuuichi]# yum install epel-release
[root@localhost yuuichi]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
[root@localhost yuuichi]# yum remove php*
[root@localhost yuuichi]# yum --enablerepo=remi-php73 install php73 php73-php php73-php-cli php73-php-common php73-php-devel php73-php-gd php73-php-mbstring php73-php-mcrypt php73-php-mysql php73-php-pdo php73-php-pear.noarch php73-php-process php73-php-snmp php73-php-xml php73-php-opcache
[root@localhost yuuichi]# systemctl restart httpd

しかし、これでインストールした環境だと、Apacheからの利用でPHPの拡張モジュールが読み込めないエラーが発生して、MySQLのPDOドライバとかが利用できなくなってしまいました。

php73が付かない名前で、リポジトリだけremi-php73を指定してやると問題なかったです。なぜ?

[root@localhost yuuichi]# yum --enablerepo=remi-php73 install php php-cli php-common php-devel php-gd php-mbstring php-mcrypt php-mysql php-pdo php-pear.noarch php-process php-snmp php-xml php-opcache php-pecl-imagick
[root@localhost yuuichi]# systemctl restart httpd

ひとまずこれでphpinfoを表示してみるとちゃんとモジュール読み込まれてる。

以上でCentOS 7上で、Apache 2.4+PHP7.3+MariaDB 10.3の組み合わせでWordPressを動かすところまで行きました。
このブログの環境をローカルで復元して動作問題なし。
これをベースにさくらのVPS上のOSもアップデートできそうです。

新プラン追加!さくらのVPS