Building extra php version 5.0.4 with mysql, libpdf and imagick


Some private company I work for have an expensive licence (EUR 800) for libpdf 6.0.4 working only with php 5.0.3 (according to documentation). Because it is compiled against PHP_API 20041030 otherwise throws this error:

Module compiled with module API=20041030, debug=0, thread-safety=0

PHP 5.0.4 works also fine.

So I've decided to register another suffix to compile <whatever>.phppdf with php running as cgi /usr/lib/cgi-bin/php-cgi-5.0.4.


Compiling it all together

Compiling ImageMagick

tar -xjf ImageMagick-6.2.9-8.tar.bz2
cd ImageMagick-6.2.9
./configure --with-x
make install

note: That –with-x must be there, because imagick.c (imagick.h to be precise) defines structure imagick_t with draw_context variable. This item's type depends on version. Once it is DrawContext and then it is DrawingWand*.

note: Or you can change the type between this two

DrawingWand*    draw_context ; /*new api */
DrawContext     draw_context ;

note: If you run into compiling problems with strcpy or atexit, this is because of gcc 4.3. It is the new gcc's design/api problem, nothing serious.


Magick++/lib/Image.cpp:3915: error: 'atexit' was not declared in this scope

add this line


#include <cstdlib>

Adding imagick into PHP's tree

tar -xzf php-5.0.4.tar.gz
cd php-5.0.4/ext
tar -xzf imagick-0.9.13.tgz
mv imagick-0.9.13 imagick

Compiling PHP

rm configure
./buildconf --force
Here you can check "./configure --help" if it hase --with-imagick option
./configure --with-imagick --with-mysql

Extracting the php-cgi binary

cp php-5.0.4/sapi/cgi/php /usr/lib/cgi-bin/php-cgi-5.0.4

And Apache

So here is a short debian oriented how-to register new .phppdf suffix to get compiled by /usr/lib/cgi-bin/php-cgi-5.0.4.

  • a2enmod action
  • mod-available/phppdf.conf
    AddHandler php-script .phppdf .phppdf
    Action php-script /cgi-bin/php-cgi-5.0.4
  • ln -s sites-available/phppdf.conf sites-enabled/phppdf.conf
  • /etc/init.d/apache2 restart

That's all!

linux/php.txt · Last modified: 2009/05/18 03:11 by admin