php-gdが動作していない
概要
「php-gdが動作していないのでなんとかして」の対応メモ。
現象
php-gdが動作していない。
$ php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/gd.so' - /usr/lib64/php/modules/gd.so: undefined symbol: gdImageWebpCtx in Unknown on line 0 $ php -m | grep gd $ php -r 'var_dump(gd_info());' PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/gd.so' - /usr/lib64/php/modules/gd.so: undefined symbol: gdImageWebpCtx in Unknown on line 0 PHP Fatal error: Call to undefined function gd_info() in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0
確かにシンボルがない。
互換のないsoにリンクしているようだ。
$ nm -D /usr/lib64/libgd.so.3 | grep gdImageWebpCtx
最新版のgdを入れてみる
更新があるので、gdを最新のものにupdateしてみる
$ sudo yum --disablerepo=* --enablerepo=remi update gd-last [sudo] password for pen: Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * remi: remi.kazukioishi.net Setting up Update Process Resolving Dependencies --> Running transaction check ---> Package gd-last.x86_64 0:2.1.0-0.10.725ba9d.el6.remi will be updated ---> Package gd-last.x86_64 0:2.1.0-2.el6.remi will be an update --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Updating: gd-last x86_64 2.1.0-2.el6.remi remi 129 k Transaction Summary ======================================================================================================================== Upgrade 1 Package(s) Total download size: 129 k Is this ok [y/N]:
結果変わらず
$ nm -D /usr/lib64/libgd.so.3 | grep gdImageWebpCtx
gdのバージョンをひとつ戻してみる
$ sudo yum --disablerepo=* --enablerepo=remi downgrade gd-last-2.1.0-1.el6.remi Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Downgrade Process Loading mirror speeds from cached hostfile * remi: remi.kazukioishi.net Resolving Dependencies --> Running transaction check ---> Package gd-last.x86_64 0:2.1.0-1.el6.remi will be a downgrade ---> Package gd-last.x86_64 0:2.1.0-2.el6.remi will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Downgrading: gd-last x86_64 2.1.0-1.el6.remi remi 134 k Transaction Summary ======================================================================================================================== Downgrade 1 Package(s) Total download size: 134 k Is this ok [y/N]: y
シンボルあり
$ nm -D /usr/lib64/libgd.so.3 | grep gdImageWebpCtx 0000000000032e20 T gdImageWebpCtx
php-gdも動作している
$ php -v PHP 5.5.4 (cli) (built: Sep 19 2013 14:42:22) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies $ php -m | grep gd gd $ php -r 'var_dump(gd_info());' ["GD Version"]=> string(5) "2.1.0" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPEG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(true) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }
結論
remiの php-gd-5.5.4-1.el6.remi.x86_64 に必要なGDは gd-last-2.1.0-1.el6.remi.x86_64 であったが、
rpm間で依存関係が正しく定義されておらず、互換のないGDがインストールされていた。
結果、dynamic linkに失敗して動作していなかった。
gdImageWebpCtx シンボルのある最終バージョンは 2.1.0-1 のようなので、gdをこれに差し替え解決した。