PHPスクリプトでグラフ及びイメージ等を動的に生成したり、フォントなどを使用する場合、別途グラフィックライブラリ、フォントライブラリをインストールする必要がある。ここでは、それらのライブラリをインストールしてPHP4で使用できるようにする。以下の組み合わせのソースによるコンパイルインストール方法を説明する。
尚、入手先は、各モジュールのWebからダウンロードしていただきたい。あえて、リンク先を記載しないのは他のサイトでも明記されているので了解されたい。
OSは、Laser5Linux6.5サーバエディション
php-4.0.6
freeetype-1.3.1
gd-1.8.4
libpng-1.2.0
jpegsrc.v6b
zlib-1.1.3
以上、 ソースの解凍先は、全て/usr/local/srcとして説明する。
1.インストールをはじめる前に
(1) 既存のバイナリのアンインストール
インストールはソースをコンパイルするので、あらかじめ同じモジュールのバイナリがインストールされている場合は、アンインストールすること。
(2) Apacheの停止
Apacheが動いている場合は止めておく。
2.zlibのコンバイル、インストール
# tar zxvf zlib-1.1.3.tar.gz
# cd zlib-1.1.3
# ./configure --enable-shared
エラーがなければ、
# make install
3.libpngのコンパイル、インストール
# tar zxvf libpng-1.2.0
# cd libpng-1.2.0
scriptsフォルダの中にMakefileがある為、シンボルリンクを張る(使用のOSに合わせてMakefileを選択すること)。この場合は、Linuxを選択している。
# ln -s scripts/makefile.linux Makefile
# make install
4.libjpegのコンパイル、インストール
# tar zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --enable-shared --enable-static
エラーがなければ、
# make install
5.freetypeのコンパイル、インストール
# tar zxvf freetype-1.3.1.tar.gz
# cd freetype-1.3.1
# ./configure --enable-shared --enable-static
エラーがなければ、
# make install
6.gdのコンパイル、インストール
# tar zxvf gd-1.8.4.tar.gz
# cd gd-1.8.4
Makefileを内容を以下のように編集する。
# vi Makefile
省略
CFLAGS=-O -DHAVE_LIBPNG -DHAVE_LIBJPEG -DJISX0208 -DHAVE_LIBTTF
省略
LIBS=-lgd -lpng -lz -ljpeg -lm -lttf
省略
INCLUDEDIRS=-I. -I/usr/include/freetype2 -I/usr/include/X11 -I/usr/X11R6/include/X11
-I/usr/local/include
を以下に訂正。
INCLUDEDIRS=-I. -I/usr/local/include/freetype
-I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include
省略
# make install
7.PHP4のコンパイル、インストール
# tar zxvf php-4.0.6.tar.gz
# cd php-4.0.6
config.phpというファイルを作り、configureパラメータを以下の内容で記述する。
# vi /tmp/config.php
./configure --enable-track-vars
--with-apxs=/usr/local/apache/bin/apxs \
--enable-versioning --enable-trans-sid --with-gd=/usr/local \
--with-png-dir=/usr/local/src --with-jpeg-dir=/usr/local/src \
--with-zlib-dir=/usr/local/src --with-ttf --enable-mbstring \
--enable-mbstr-enc-trans
ファイルができたら、シェルで実行してlogファイルへリダイレクトする(エラーチェックを容易にするため)。
# sh /tmp/config.php > log
ログの内容を確認。エラーがなく、以下の内容であれば成功!
# less log
省略
checking whether to include GD support... yes
checking whether to enable truetype string function in gd... no
checking for the location of libjpeg... yes
checking for jpeg_read_header in -ljpeg... yes
checking for the location of libpng... yes
checking for png_info_init in -lpng... yes
checking for the location of libXpm... no
If configure fails try --with-xpm-dir=<DIR>
checking for freetype(2)... no
If configure fails try --with-freetype-dir=<DIR>
checking whether to include include FreeType 1.x support... yes
checking whether to include T1lib support... no
checking for gdImageString16 in -lgd... yes
checking for gdImagePaletteCopy in -lgd... yes
checking for gdImageCreateFromPng in -lgd... yes
checking for gdImageCreateFromGif in -lgd... no
checking for gdImageWBMP in -lgd... yes
checking for gdImageCreateFromJpeg in -lgd... yes
checking for gdImageCreateFromXpm in -lgd... yes
checking for gdImageCreateTrueColor in -lgd... no
checking for gdImageSetTile in -lgd... yes
checking for gdImageSetBrush in -lgd... yes
checking for gdImageStringFTEx in -lgd... no
checking for gdImageColorClosestHWB in -lgd... yes
checking for gdImageColorResolve in -lgd... yes
checking for gdImageGifCtx in -lgd... no
省略
# make
# make install
初期化ファイルを作成。カレントフォルダから、
# cp php.ini-dist /usr/local/lib/php.ini
8.httpd.confの編集
apacheのhttpd.confを編集する。
# cd /usr/local/apache/conf
# vi httpd.conf
省略
AddType application/x-tar .tgz
AddType image/x-icon .ico
→ AddType application/x-httpd-php
.php .php3
→ AddType application/x-httpd-php-source .phps .php3s
省略
矢印の部分を追加する。
9.ld.so.confの編集
ld.so.confの最後に以下のパスを追加する。
# vi /etc/ld.so.conf
省略
/usr/local/lib
編集が終わったら、以下を実行
# ldconfig
10.Apacheの再起動
# /usr/local/apache/bin/apachectl restart
以上
|