マイ忘備録

フィリピン関連のメモ、ワードプレス関連のメモなど

bcmathとimagickのインストール(CentOS7)

ワードプレスのサイトヘルスで、phpの推奨モジュールが入ってないというので、入れてみた。

* 警告 オプションのモジュール bcmath がインストールされていないか、無効化されています。
* 警告 オプションのモジュール imagick がインストールされていないか、無効化されています。

f:id:tagayshin:20190509124025p:plain

リンク先のドキュメントによると、bcmathは大きな数字を高速に扱うライブラリ、imagickは画像処理関連のライブラリらしい。

https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions

PHP Extensions #

bcmath – Used to improve the performance of math calculations.

imagick – Provides better image quality for media uploads. See WP_Image_Editor is incoming! for details. Smarter image resizing (for smaller images) and PDF thumbnail
support, when Ghost Script is also available.

 

bcmathのインストール

これだと

[root@xxx ~]# yum install php-bcmath

違うバージョンの依存ライブラリを見にいってエラーになる、というか古いバージョンのbcmathをリポジトリからインストールしようとしてしまうので、

Error: Package: php-bcmath-5.4.16-46.el7.x86_64 (base)
           Requires: php-common(x86-64) = 5.4.16-46.el7
           Installed: php-common-7.3.5-1.el7.remi.x86_64 (@remi-php73)
               php-common(x86-64) = 7.3.5-1.el7.remi
           Available: php-common-5.4.16-46.el7.x86_64 (base)
               php-common(x86-64) = 5.4.16-46.el7

 レポジトリを指定してインストール

[root@xxx ~]# yum --enablerepo=remi-php73 install php-bcmath

( 参考 バージョン違いによるエラー - Qiita )

 

imagickのインストール

imagickのインストールはちょっと手こずった。PCELというのをインストールしたり、php.iniに設定を記述したりと、やや面倒だった↓

 

最初、これだけでいいのかと思ったけど、動かない。たぶんこれはphp側の呼び出す機能だけなのかな。

[root@xxx ~]# yum install ImageMagick

どうもPCELが必要らしい
[root@xxx ~]# yum --enablerepo=remi-php73 install php-pear
pcelはphp-develに依存
[root@xxx ~]# yum --enablerepo=remi-php73 install php-devel
これもやっぱり必要だった
[root@xxx ~]# yum install ImageMagick-devel 
で、imagick本体をインストール(多分)
[root@xxx ~]# pecl install imagick

そして、/etc/php.ini に以下を追記 /etc/php.d/20_imagick.ini みたいなのを自動で配置してくれればいいのに、peclとかインストールする場合には手書きが必要なのかな?

extension=imagick.so

これでようやく完了。

 

アパッチを再起動

[root@xxx ~]# systemctl restart httpd

サイトヘルスの警告がようやく消えた

 

imagickのインストールは以下のサイトを参考にした。振り返ってみると、これが完結にまとまってた。

CentOSにImageMagickをインストールする - Qiita

うちの環境には、PCELが入ってなかったので、先にそのインストールが必要だった。

How to install PHP ImageMagick on CentOS 7 | LinuxHelp Tutorials

PHPでの画像処理【ImageMagick編】 | バシャログ。

 


[PR] フィリピンのディズニーランド誘致計画