くまきち

山と旅と家族が大事。
でも激しい物欲が理性と財布のタガを飛ばす
最近は自転車も乗ってる

[PHP][PDF]Haruを使ってみる(1)

2013-05-30 09:36:30 | SEまわり
PHP からの PDF 生成について、よさげなライブラリが紹介されていたので試してみた。


 【Haruで基本的なPDFを作成する(CodeZine)】
   http://codezine.jp/article/detail/7141]

まずは libharu のインストールから。

参考ページでは yum でインストールしているが、手元の環境ではできなかったので、ソースからインストールした。

wget http://libharu.org/files/libharu-2.1.0.tar.gz
tar xfz libharu-2.1.0.tar.gz
cd libharu-2.1.0
./configure
make
make install

続いて Haru のインストール。

最初、プロキシ設定がなかったため、pecl config-set http_proxy <proxy> としてみたけどダメだった。 pecl じゃなくて、pear でよかったみたい。

以下、実行時のログ。

pecl install haru
downloading haru-1.0.4.tgz ...
Starting to download haru-1.0.4.tgz (27,538 bytes)
....done: 27,538 bytes
4 source files, building
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Please provide the prefix of libharu installation [autodetect] :
building in /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4
running: /tmp/pear/temp/haru/configure --with-haru
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20100525
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for Haru PDF support... yes, shared
checking for the location of libz... no
checking for the location of libpng... no
checking for Haru in default path... found in /usr/local/
checking for HPDF_Stream_WriteToStreamWithDeflate in -lhpdf... yes
checking for HPDF_LoadPngImageFromFile in -lhpdf... yes
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1966080
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/libtool --mode=compile cc -I. -I/tmp/pear/temp/haru -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/include -I/tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/main -I/tmp/pear/temp/haru -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local//include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/haru/haru.c -o haru.lo
mkdir .libs
cc -I. -I/tmp/pear/temp/haru -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/include -I/tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/main -I/tmp/pear/temp/haru -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local//include -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/haru/haru.c -fPIC -DPIC -o .libs/haru.o
/bin/sh /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/libtool --mode=link cc -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/include -I/tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/main -I/tmp/pear/temp/haru -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local//include -DHAVE_CONFIG_H -g -O2 -o haru.la -export-dynamic -avoid-version -prefer-pic -module -rpath /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/modules haru.lo -Wl,-rpath,/usr/local//lib -L/usr/local//lib -lhpdf -lpng -lz
cc -shared .libs/haru.o -Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib -L/usr/local//lib /usr/local/lib/libhpdf.so -L/usr/lib -lpng -lz -Wl,-rpath -Wl,/usr/local//lib -Wl,-soname -Wl,haru.so -o .libs/haru.so
creating haru.la
(cd .libs && rm -f haru.la && ln -s ../haru.la haru.la)
/bin/sh /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/libtool --mode=install cp ./haru.la /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/modules
cp ./.libs/haru.so /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/modules/haru.so
cp ./.libs/haru.lai /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/modules/haru.la
PATH="$PATH:/sbin" ldconfig -n /tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/modules
----------------------------------------------------------------------
Libraries have been installed in:
/tmp/pear/temp/pear-build-rootXsIh94/haru-1.0.4/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

running: make INSTALL_ROOT="/tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4" install
Installing shared extensions: /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4/usr/local/lib/php/extensions/no-debug-non-zts-20100525/
running: find "/tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4" | xargs ls -dils
74 4 drwxr-xr-x 3 root root 4096 5月 30 08:51 2013 /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4
95 4 drwxr-xr-x 3 root root 4096 5月 30 08:51 2013 /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4/usr
96 4 drwxr-xr-x 3 root root 4096 5月 30 08:51 2013 /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4/usr/local
97 4 drwxr-xr-x 3 root root 4096 5月 30 08:51 2013 /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4/usr/local/lib
98 4 drwxr-xr-x 3 root root 4096 5月 30 08:51 2013 /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4/usr/local/lib/php
99 4 drwxr-xr-x 3 root root 4096 5月 30 08:51 2013 /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4/usr/local/lib/php/extensions
100 4 drwxr-xr-x 2 root root 4096 5月 30 08:51 2013 /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4/usr/local/lib/php/extensions/no-debug-non-zts-20100525
94 300 -rwxr-xr-x 1 root root 307054 5月 30 08:51 2013 /tmp/pear/temp/pear-build-rootXsIh94/install-haru-1.0.4/usr/local/lib/php/extensions/no-debug-non-zts-20100525/haru.so

Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/haru.so'
install ok: channel://pecl.php.net/haru-1.0.4
configuration option "php_ini" is not set to php.ini location
You should add "extension=haru.so" to php.ini

最後のところに、php.ini の extension に指定をするように指示がある。

言われたとおりにして、httpd を再起動。

インストールは終わり。

最新の画像もっと見る