Page 1 of 1

AIX 6.1, PHP 5.3.10, imagick 3.0.1

Posted: Thu Mar 22, 2012 2:41 pm
by wkrauth
I am trying to add the imagick.so library extension to a new installation. I am compiling PHP from scratch to include a number of modules that are not in it by default such as oci8, etc.

After completing compiles on both PHP and imagick, and adding the imagick.so extension to php.ini, starting Apache 2.2.21 results in this error in the apache error.log

PHP Warning: PHP Startup: Unable to load dynamic library '/opt/freeware/lib/php/extensions/no-debug-zts-2009 0626/imagick.so' - rtld: 0712-001 Symbol executor_globals was referenced\n from module /opt/freeware/lib /php/extensions/no-debug-zts-20090626/imagick.so(), but a runtime definition\n of the symbol was not fou nd.\nrtld: 0712-001 Symbol core_globals was referenced\n from module /opt/freeware/lib/php/extensions/no -debug-zts-20090626/imagick.so(), but a runtime definition\n of the symbol was not found.\nrtld: 0712-00 1 Symbol sqrt was referenced\n from module /opt/freeware/lib/php/extensions/no-debug-zts-20090626/imagic k.so(), but a runtime definition\n of the symbol was not found. in Unknown on line 0

I have tried both manual (configure, make) and pecl install imagick. Both routes create the imagick.so file, but always results in the above apache error.

I posted this to the bug forum of PHP, and it was suggested that I post here instead as it is not a bug. They indicated that I am mixing thread-safe and non-thread-safe installations.

phpinfo.php says that my php is thread-safe, but I am not able to compile it as non-thread-safe. The configure directives of (--disable-zts-maintainer, --enable-zts-maintainer, --disable-zts) make no difference, the result is always thread safe.

If this is a thread safe / non thread safe issue, how do I resolve it?

Re: AIX 6.1, PHP 5.3.10, imagick 3.0.1

Posted: Tue Mar 27, 2012 5:04 pm
by FrankFegert
Hello,

i was facing the same problem, but with the PECL-APC PHP extension. AIX and PHP version are the same here, Apache is at 2.2.15. After some digging through the various source files this is what i've found:

If you build PHP with the "--with-apxs*" configure option, then the "--enable-maintainer-zts" option gets explicitly set too. This is caused by the following code around line 6285 in configure:

Code: Select all

  ...
  if test "$APXS_MPM" != "prefork" && test "$APXS_MPM" != "peruser"; then

  enable_maintainer_zts=yes
  ...
The content of the APXS_MPM variable is determined around line 5479 in configure:

Code: Select all

  ...
  APXS_CFLAGS=`$APXS -q CFLAGS`
  APXS_MPM=`$APXS -q MPM_NAME`
  APU_BINDIR=`$APXS -q APU_BINDIR`
  ...
Finally APXS (in my case /opt/freeware/sbin/apxs) gets its variable values from those lines:

Code: Select all

...
my $installbuilddir = "/var/www/build";
get_config_vars("$installbuilddir/config_vars.mk",\%config_vars);
...
For me, changing "MPM_NAME = worker" to "MPM_NAME = prefork" in /var/www/build/config_vars.mk and rebuilding PHP worked.

HTH & best regards,

Frank Fegert

Re: AIX 6.1, PHP 5.3.10, imagick 3.0.1

Posted: Wed Mar 28, 2012 2:50 pm
by wkrauth
Frank,

Thank you for the response!

I changed the MPM_NAME value as you suggested, and recompiled, but then apache will not start, giving this error:

"Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.
Pre-configuration failed"

Based on my original error, does it sound to you like a thread-safe / non-thread-safe issue? If so, then do I need to find a way to compile the imagick library as thread-safe?

Regards,
Wayne Krauth

Re: AIX 6.1, PHP 5.3.10, imagick 3.0.1

Posted: Wed Mar 28, 2012 4:24 pm
by FrankFegert
Hello,

no, now you just need to use the thread-safe Apache MPM (aka "prefork") instead of the threaded "worker" MPM. Did you build Apache yourself? If so, use the "--with-mpm=prefork" configure option and rebuild Apache. I'm using the prebuild one from http://www.perzl.org/aix/. This one comes with several MPMs under /opt/freeware/sbin/

Code: Select all

/opt/freeware/sbin/httpd -> httpd.prefork
/opt/freeware/sbin/httpd.event
/opt/freeware/sbin/httpd.prefork
/opt/freeware/sbin/httpd.worker
To enable the thread-safe "prefork" MPM i stopped Apache, moved /opt/freeware/sbin/httpd to /opt/freeware/sbin/httpd.worker and created a link from /opt/freeware/sbin/httpd to /opt/freeware/sbin/httpd.prefork. After this everything should work fine with your PHP module.

HTH & best regards,

Frank Fegert

Re: AIX 6.1, PHP 5.3.10, imagick 3.0.1

Posted: Fri Mar 30, 2012 10:35 am
by wkrauth
Frank,

This did allow both apache and php to start and are now working in non-thread-safe mode.

However, apache still reports the imagick error when starting, and phpinfo.php does not show imagick as loaded/available.

PHP Warning: PHP Startup: Unable to load dynamic library '/opt/freeware/lib/php/extensions/no-debug-zts-20090626/imagick.so' - rtld: 0712-001 Symbol executor_globals_id was referenced\n from module /opt/freeware/lib/php/extensions/no-debug-zts-20090626/imagick.so(), but a runtime definition\n of the symbol was not found.\nrtld: 0712-001 Symbol core_globals_id was referenced\n from module /opt/freeware/lib/php/extensions/no-debug-zts-20090626/imagick.so(), but a runtime definition\n of the symbol was not found.\nrtld: 0712-001 Symbol ts_resource_ex was referenced\n from module /opt/freeware/lib/php/extensions/no-debug-zts-20090626/imagick.so(), but a runtime definition\n of the symbol was not found.\nrtld: 0712-001 Symbol sqrt was referenced\n from module /opt/freeware/lib/php/extensions/no-debug-zts-20090626/imagick.so(), but a runtime definition\n of the symbol was not found.\nrtld: 0712-001 Symbol ts_allocate_id was referenced\n from module /opt/freeware/lib/php/extensions/no-debug-zts-20 in Unknown on line 0

Perhaps I need to recompile imagick with a flag for non-thread-safe, or maybe a static compile?

Thanks again for your help!
Wayne Krauth


FrankFegert wrote:Hello,

no, now you just need to use the thread-safe Apache MPM (aka "prefork") instead of the threaded "worker" MPM. Did you build Apache yourself? If so, use the "--with-mpm=prefork" configure option and rebuild Apache. I'm using the prebuild one from http://www.perzl.org/aix/. This one comes with several MPMs under /opt/freeware/sbin/

Code: Select all

/opt/freeware/sbin/httpd -> httpd.prefork
/opt/freeware/sbin/httpd.event
/opt/freeware/sbin/httpd.prefork
/opt/freeware/sbin/httpd.worker
To enable the thread-safe "prefork" MPM i stopped Apache, moved /opt/freeware/sbin/httpd to /opt/freeware/sbin/httpd.worker and created a link from /opt/freeware/sbin/httpd to /opt/freeware/sbin/httpd.prefork. After this everything should work fine with your PHP module.

HTH & best regards,

Frank Fegert

Re: AIX 6.1, PHP 5.3.10, imagick 3.0.1

Posted: Fri Mar 30, 2012 2:18 pm
by FrankFegert
Hello Wayne,

i tried to build and load imagick extension with the Apache/PHP i'm using. In general it works over here - see the attached phpinfo() screenshot. Although i only tested as far as loading, no actual PHP code is referencing the extension at the moment. The environment i used for this:

Code: Select all

CC="xlc_r"; export CC
CXX="xlC_r"; export CC
CFLAGS="-ma -O3 -qstrict -qoptimize=3 -qmaxmem=16384 -DSYSV -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_ALL_SOURCE -DFUNCPROTO=15 -I/opt/freeware/include"; export CFLAGS
CXXFLAGS=$CFLAGS; export CXXFLAGS
LD=ld; export LD
LDFLAGS="-L/opt/freeware/lib -Wl,-bmaxdata:0x80000000 -lm"; export LDFLAGS

/opt/freeware/bin/phpize
./configure --with-php-config=/opt/freeware/bin/php-config --with-imagick=/opt/freeware/
gmake
Mind the "-lm" in the LDFLAGS, this will get rid of the "0712-001 Symbol sqrt was referenced" you're seeing. As far as the dependencies go, only the PHP was modified, all others are pristine copies from perzl.org. So there should really be no need to rebuild ImageMagick or anything else.

Did you remember to run a "make clean" in the imagick extensions source directory after rebuilding PHP thread-safe? Could you try to build and load another PHP extension for testing purposes? E.g. APC and XDebug are known to work.

Also, could you run a ldd on the imagick.so? Should look like this:

Code: Select all

ldd /opt/freeware/lib/php/modules/imagick.so | sort
         /opt/freeware/lib/libMagickCore.a(libMagickCore.so.5)
         /opt/freeware/lib/libMagickWand.a(libMagickWand.so.5)
         /opt/freeware/lib/libbz2.a(libbz2.so.1)
         /opt/freeware/lib/libexpat.a(libexpat.so.1)
         /opt/freeware/lib/libfontconfig.a(libfontconfig.so.1)
         /opt/freeware/lib/libfreetype.a(libfreetype.so.6)
         /opt/freeware/lib/libiconv.a(shr4.o)
         /opt/freeware/lib/libjasper.a(libjasper.so.1)
         /opt/freeware/lib/libjbig.a(shr.o)
         /opt/freeware/lib/libjpeg.a(libjpeg.so.62)
         /opt/freeware/lib/liblcms.a(liblcms.so.1)
         /opt/freeware/lib/liblzma.a(liblzma.so.0)
         /opt/freeware/lib/libpng12.a(libpng12.so.0)
         /opt/freeware/lib/libtiff.a(libtiff.so.3)
         /opt/freeware/lib/libxml2.a(libxml2.so.2)
         /opt/freeware/lib/libz.a(libz.so.1)
         /unix
         /usr/lib/libIM.a(shr.o)
         /usr/lib/libX11.a(shr4.o)
         /usr/lib/libXext.a(shr.o)
         /usr/lib/libc.a(shr.o)
         /usr/lib/libc.a(shr_64.o)
         /usr/lib/libcrypt.a(shr.o)
         /usr/lib/libcrypt.a(shr_64.o)
         /usr/lib/libgaimisc.a(shr.o)
         /usr/lib/libgair4.a(shr.o)
         /usr/lib/libodm.a(shr.o)
         /usr/lib/libpthread.a(shr_xpg5.o)
         /usr/lib/libpthreads.a(shr_comm.o)
         /usr/lib/libpthreads.a(shr_xpg5.o)
Best regards,

Frank Fegert

Re: AIX 6.1, PHP 5.3.10, imagick 3.0.1

Posted: Tue Apr 03, 2012 12:36 pm
by wkrauth
Frank thank you for your assistance, it is most appreciated! I learned a lot from your posts.

The problem has been solved. The issue was not with imagick, but with the build of php 5.3.10. In AIX, when you do a make install on php, it fails with this error excerpt:

chmod 755 /opt/freeware/lib/httpd/modules/libphp5.so
chmod: /opt/freeware/lib/httpd/modules/libphp5.so: A file or directory in the path name does not exist.
apxs:Error: Command failed with rc=65536

It appears that the Makefile created by configure, creates an error in libphp5.la, and was therefore unable to find the library to complete the install. As a work-around, I was simply copying the libphp5.so file to the destination. But the better solution was to fix the libphp5.la file to point at libphp5.so instead of libphp5.a.

The script below is executed after gmake, but before gmake install. This fixes the libphp5.la file and allows installation to work correctly.

######## fixlibs script ########
cp libphp5.la libphp5.la.orig
cp libs/libphp5.la libs/libphp5.la.orig

sed s/libphp5.a/libphp5.so/g <libphp5.la.orig > libphp5.la
sed s/libphp5.a/libphp5.so/g < libs/libphp5.la.orig > libs/libphp5.la
####### end of fixlibs script #######

Now phpinfo.php shows the imagick module loaded. All is well!

Regards,
Wayne Krauth

Re: AIX 6.1, PHP 5.3.10, imagick 3.0.1

Posted: Thu Jul 03, 2014 1:49 am
by Aniruddh
I am also finding the same problem but with ibm_db2.so. Please help me with this problem:

Problem description:

I am trying to include 2 php extensions, db2_ibm.so and pdo_ibm.so, in the php.ini (I have edited that php.ini file which was shown in <?php phpinfo() ?>).

In the PHP cli version, using the command `php -m`, I can see that the modules are being rightly loaded. I can see the versions ibm_db2 1.9.1 and pdo_ibm 1.3.2

However, when I try to do the same via Apache it would not connect. I moved on and looked at the Apache error logs and found the following.

For db2_ibm.so, I got the following error:

Code: Select all

[syntax=php] [syntax=php]PHP Warning:  PHP Startup: Unable to load dynamic library 
    '/opt/freeware/lib/php/modules/ibm_db2_5.2.1.so'
    - rtld: 0712-001 Symbol executor_globals was referenced 
    from module /opt/freeware/lib/php/modules/ibm_db2_5.2.1.so(), 
    but a runtime definition of the symbol was not found.
    in Unkno
[/syntax]wn on line 0[/syntax]

And for pdo_ibm.so:

Code: Select all

PHP Warning:  PHP Startup: pdo_ibm: Unable to initialize module
    Module compiled with module API=20060613, debug=0, thread-safety=0
    PHP    compiled with module API=20060613, debug=0, thread-safety=1
    These options need to match in Unknown on line 0
Following Versions are installed on my system (AIX 7.1):
  • PHP 5.2.17
  • Apache 2.2.16
  • DB2 9.7.4
I have installed Apache and PHP them from RPM packages.

Please do suggest some solution soon as I am stuck here for days now. Thanks a lot!