Linuxサーバ奮戦記 --- JpGraph ---  Mod.16Jan2010   >>TOP

PHP環境下で JpGraph をインストールすればグラフを描くことが可能になる。

準備

Shinta's Site さんのページを参考にしてメモしている。
JpGraph をインストールする前に以下のGDモジュールなどのライブラリを入れる。
# tar zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure
# make
# make install

# tar zxvf libpng-1.2.9.tar.gz
# cd libpng-1.2.9
# cp scripts/makefile.linux Makefile
# make
# make install

# tar zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --enable-shared
# make
# make install

# tar zxvf freetype-2.3.5.tar.gz
# cd freetype-2.3.5
# ./configure --enable-static
# make
# make install

# tar zxvf gd-2.0.35.tar.gz
# cd gd-2.0.35
# ./configure --without-libiconv-prefix
# make
# make install

PHP5のインストールには以下のように config し直す。(13Dec2007)
./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-zend-multibyte \
--enable-mbstring \
--enable-mbregex \
--with-pgsql=/usr/local/pgsql \
--with-gd=/usr/local \
--with-freetype-dir=/usr/local \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-zlib-dir=/usr/local \
--enable-gd-native-ttf \
--enable-gd-jis-conv

Fedora 9 の x86_64 版ではGDがうまくインストールできなかった。(15Feb2009)
ソースからでなく上記を yum でインストールしたのち以下の様にPHP5を config したらいけた。
また,JpGraphで今までは日本語テキスト表示に mb_convert_encoding で UTF-8 だったのに EU-JP にしなければ文字化けしてしまう。何が違うんだろう?
./configure \
--with-libdir=lib64 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-zend-multibyte \
--enable-mbstring \
--enable-mbregex \
--with-pgsql=/usr/local/pgsql \
--with-gd \
--with-freetype-dir=/usr/local \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-zlib-dir=/usr/local \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gmp=/usr/local \
--with-mcrypt=/usr/local \
--with-mhash=/usr/local


JpGraph のインストール  30Nov2006

まずは,以下のものを入手。
JpGraphで日本語を扱うには、文字コードをUTF-8にする必要がある。 # bunzip2 sazanami-20040629.tar.bz2
# tar xf sazanami-20040629.tar
# mkdir /usr/local/fonts
# mkdir /usr/local/fonts/truetype
# cd sazanami-20040629
# cp sazanami-gothic.ttf /usr/local/fonts/truetype/sazanami-gothic.ttf
# cp sazanami-mincho.ttf /usr/local/fonts/truetype/sazanami-mincho.ttf

jpgraph-2の場合
# tar zxvf jpgraph-2.1.4.tar.gz
# cd jpgraph-2.1.4/src
# vi jpg-config.inc.php

以下の項目を太字に変更する。
  • // DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/"); →
    DEFINE("TTF_DIR","/usr/local/fonts/truetype/");
  • // DEFINE("MBTTF_DIR","/usr/share/fonts/ja/TrueType/"); →
    DEFINE("MBTTF_DIR","/usr/local/fonts/truetype/");
  • DEFINE('MINCHO_TTF_FONT','ipam.ttf'); →
    DEFINE('MINCHO_TTF_FONT','sazanami-mincho.ttf');
  • DEFINE('PMINCHO_TTF_FONT','ipamp.ttf'); →
    DEFINE('PMINCHO_TTF_FONT','sazanami-mincho.ttf');
  • DEFINE('GOTHIC_TTF_FONT','ipag.ttf'); →
    DEFINE('GOTHIC_TTF_FONT','sazanami-gothic.ttf');
  • DEFINE('PGOTHIC_TTF_FONT','ipagp.ttf'); →
    DEFINE('PGOTHIC_TTF_FONT','sazanami-gothic.ttf');
# mkdir /usr/local/jpgraph
# tar cf - . | (cd /usr/local/jpgraph/; tar xf -)
# mkdir /tmp/jpgraph_cache
# chmod 777 /tmp/jpgraph_cache



jpgraph-3の場合
# mkdir jpgraph-3.0.7
# cd jpgraph-3.0.7
# bzcat jpgraph-3.0.7.tar.bz2 | tar xvf -
# mv src /usr/local/jpgraph
# vi /usr/local/jpgraph/jpg-config.inc.php
以下の項目を太字に変更する。
  • // define('TTF_DIR','/usr/share/fonts/truetype/'); →
    define("TTF_DIR","/usr/local/fonts/truetype/");
  • // define('MBTTF_DIR','/usr/share/fonts/truetype/'); →
    define("MBTTF_DIR","/usr/local/fonts/truetype/");
# vi /usr/local/jpgraph/jpgraph_ttf.inc.php
以下の項目を太字に変更する。
  • define('MINCHO_TTF_FONT','ipam.ttf'); →
    define('MINCHO_TTF_FONT','sazanami-mincho.ttf');
  • define('PMINCHO_TTF_FONT','ipamp.ttf'); →
    define('PMINCHO_TTF_FONT','sazanami-mincho.ttf');
  • define('GOTHIC_TTF_FONT','ipag.ttf'); →
    define('GOTHIC_TTF_FONT','sazanami-gothic.ttf');
  • define('PGOTHIC_TTF_FONT','ipagp.ttf'); →
    define('PGOTHIC_TTF_FONT','sazanami-gothic.ttf');
# mkdir /tmp/jpgraph_cache
# chmod 777 /tmp/jpgraph_cache