LibGD2.3.3をCentOS6にソースインストール

実践環境で使う場合はご注意ください。

CentOS6 + PHP7.4.33 + LibGD 2.3.3 の組合せは configure は通って make でエラーになるので注意です。
詳しくはこちら

目的

PHP7.4.33をCentOS6にインストールしようとしたところ configure で次のエラーが発生しました。

checking whether to enable JIS-mapped Japanese font support in GD... no
checking for gdlib >= 2.1.0... no
configure: error: Package requirements (gdlib >= 2.1.0) were not met:

Requested 'gdlib >= 2.1.0' but version of gd-devel is 2.0.34

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables GDLIB_CFLAGS
and GDLIB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

PHP7.4.0 からLibGDは同梱されなくなりました。

特徴

  • ソースコードからのインストール
  • 複数バージョンの共存

特定バージョンでの開発や動作確認など開発環境での用途を目的としています。

環境

実施日2022-12-10
サーバさくらのVPS 2G
OSCentOS 6.10
cat /etc/redhat-release
CentOS release 6.10 (Final)
rpm -qa | grep centos-release
centos-release-6-10.el6.centos.12.3.x86_64

事前準備

LibGD 2.3.3

GitHubからダウンロードURLを確認します

https://github.com/libgd/libgd/tags

2022年12月10日時点では gd-2.3.3 が最新です。

gd-2.3.3 欄の右下「Downloads」をクリックします。

ページが変わって下の方「Assets」に「libgd-2.3.3.tar.gz」があります。
「Source code (tar.gz)」ではないので注意

「libgd-2.3.3.tar.gz」の文字を右クリックして「リンクのアドレスをコピー(※)」
(※)ブラウザによって表記が異なります。リンクされてるURLが取得できれば方法はなんでも良いです

wget https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.gz

インストール

ls -la /usr/local/src
ls -la /usr/local/lib

mkdir /usr/local/src/gd-2.3.3

cd /usr/local/src/gd-2.3.3

wget https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.gz

tar xvzf libgd-2.3.3.tar.gz

cd libgd-2.3.3

./configure --prefix=/usr/local/lib/libgd-2.3.3

make

make install

注意事項

CentOS 6 に PHP7.4.33 を LibGD2.3.3 でインストールしようとすると make で次のエラーになります。

/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c: In function ‘zm_startup_gd’:
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c:1140: error: ‘GD_FLIP_HORINZONTAL’ undeclared (first use in this function)
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c:1140: error: (Each undeclared identifier is reported only once
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c:1140: error: for each function it appears in.)
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c:1141: error: ‘GD_FLIP_VERTICAL’ undeclared (first use in this function)
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c:1142: error: ‘GD_FLIP_BOTH’ undeclared (first use in this function)
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c: In function ‘zif_imageflip’:
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c:4706: error: ‘GD_FLIP_VERTICAL’ undeclared (first use in this function)
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c:4710: error: ‘GD_FLIP_HORINZONTAL’ undeclared (first use in this function)
/usr/local/src/php-7.4.33-mysqlc-mysqlnd/php-7.4.33/ext/gd/gd.c:4714: error: ‘GD_FLIP_BOTH’ undeclared (first use in this function)
make: *** [ext/gd/gd.lo] エラー 1

configure は通ったので安心してましたがダメっぽいです。

ということで、LibGD のバージョンを下げながら調整してみます。