PHP5.5 の gd を PHP5.2 で動かす方法 (debian)
PHP5.5 が動く apache サーバなんて簡単には用意出来ないので、PHP5.2 (残念ながら squeeze はまだコレ) で PHP5.5 版 GD を動かす方法のメモです。
諦めかけた所にピンポイントでアドバイスをくれた mathane さんに感謝
手順
試行錯誤を一通りして、とりあえず解決した手順。
php-5.5.0/ext/gd を適当な場所にコピーする
~$cp -r php-5.5.0/ext/gd ~/src/php/.
- 必要なライブラリを入れる。(なくても有ると勘違いされるので)
sudo apt-get install libxpm-dev
- /usr にあるのに自分で解決してくれないので、-dir で指定しまくる。
~/src/php/gd$ phpize ~/src/php/gd$ ./configure --with-freetype-dir=/usr/include/freetype2 --with-jpeg-dir=/usr\ --with-t1lib=no --with-xpm-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr
- config.h の #undef HAVE_LIBT1 を有効にする。(出来れば configure で解決したいのですが =no が効きません。残念)
/* */ #undef HAVE_LIBT1
- gd.c の #include の並びの後ろに
#ifndef PHP_FE_END #define PHP_FE_END {NULL, NULL, NULL} #endif PHP_FE_END
あとは make と make install して apache restart
試行錯誤
あとでググって来れるように全部記録。
/home/yoya/src/php/gd/gd.c:57:22: error: X11/xpm.h: そのようなファイルやディレクトリはありません
- → sudo apt-get install libxpm-dev
/home/yoya/src/php/gd/gd.c:65:19: error: t1lib.h: そのようなファイルやディレクトリはありません
- → sudo apt-get install libt1-dev
/usr/include/ft2build.h:56:38: error: freetype/config/ftheader.h: そのようなファイルやディレクトリはありません
- → ./configure に --with-freetype-dir=/usr/include/freetype2
/home/yoya/src/php/gd/gd.c:1030: error: ‘PHP_FE_END’ undeclared here (not in a function)
- ↓これはいつも通りで。 参考 > PHP 拡張のコンパイルで PHP_FE_END undeclared here - yoyaのメモ
#ifndef PHP_FE_END
#define PHP_FE_END {NULL, NULL, NULL}
#endif PHP_FE_END
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/gd.so' - /usr/lib/php5/20090626/gd.so: undefined symbol: php_gd_gdImageJpegCtx in Unknown on line 0
- → ./configure に --with-jpeg-dir=/usr
undefined symbol: T1_errno
- config.h の #undef HAVE_LIBT1 を有効に
undefined symbol: gdImageCreateFromXpm
- → ./configure に --with-xpm-dir=/usr