GD使いたかったのでPHPをソースからインストールすることに。
(rpmファイルをいじればすむことなのかな)
デフォルトだとGD関連の関数を実行できない。
[mikeda@cent try]$ php -r 'imagecreatetruecolor(1,1);'
PHP Fatal error: Call to undefined function imagecreatetruecolor() in Command line code on line 1
とりあえずcoifigureオプションを決める。
./configure \ --prefix=/usr/local/php \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/usr/local/mysql \ --with-mcrypt \ --enable-roxen-zts \ --enable-zend-multibyte \ --enable-track-vars \ --enable-mbstring \ --enable-mbregex \ --with-zlib \ --with-gd \ --with-jpeg-dir=/usr/local \ --with-png-dir=/usr/local \ --with-freetype-dir=/usr/local \ --enable-gd-native-ttf
あとは実際やってみて、なんか足りないと言われるたびにそれを入れて再挑戦の繰り返し。
The output of /usr/local/apache2/bin/apxs follows:
./configure: line 6669: /usr/local/apache2/bin/apxs: No such file or directory
[root@cent php-5.2.6]# find /usr -name apxs
→見つからない。[root@cent php-5.2.6]# yum -y install httpd-devel
[root@cent php-5.2.6]# find /usr -name apxs
/usr/sbin/apxs
→with-apxs2=/usr/local/apache2/bin/apxsのパスを/usr/sbin/apxsに変更
Configuring extensions
checking whether to enable LIBXML support... yes
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
[root@cent php-5.2.6]# yum -y install libmcrypt libmcrypt-devel
configure: error: Cannot find MySQL header files under /usr/local/mysql.
Note that the MySQL client library is not bundled anymore!
[root@cent php-5.2.6]# yum -y install mysql-devel
やっと./configure成功。make、make install。
以前入ってたやつもとりあえずそのままでPATHだけ変更して新しいのが優先して呼び出されるように。
echo export PATH=/usr/local/php/bin:\$PATH >> /etc/bashrc
乱暴すぎかな・・・
まぁこれで目標達成。
[mikeda@cent try]$ php -r 'imagecreatetruecolor(1,1);'
→エラーがでない。
・・・と思いきや、ブラウザから呼び出すとimagejpeg()の画像が表示されない。何も返してこない。
header("Content-type: image/jpeg");
としてるのにそれも適用されてない。
ローカルからCLIで実行するとちゃんと出力されるのに・・・
・・・mod_phpが更新されてませんでした。けっこうハマりまった。
で、apache入れ直してPHPをリコンパイルしたら更新された。
理由がはっきりわからず。