PHP cannot load shared libraries

PHPshared-libraries

I'm new to posting on this forum. Hopefully I don't make any social mistakes here.

I have:

  1. Linux system (64 bit)
  2. php compiled and installed with the following options:

./configure
–enable-maintainer-zts
–with-pdo-mysql
–with-mysqli=mysqlnd
–prefix=/etc/httpd/php
–with-gd
–with-config-file-path=/etc/httpd/php
–disable-cgi
–with-zlib
–with-gettext
–with-gdbm
–enable-zip
–enable-mbstring
–with-zlib-dir=/usr/include
–with-libxml-dir=/usr/lib64
–with-mcrypt=/usr/lib64
–with-jpeg-dir=/usr
–with-png-dir=/usr
–with-apxs2=/etc/httpd/bin/apxs
–enable-shared


  1. php.ini with the following settings:
extension_dir = "/usr/lib64/php/modules/"

extension=mongo.so
extension=curl.so
extension=json.so
extension=fileinfo.so
extension=gd.so
extension=mbstring.so
extension=mcrypt.so
extension=phar.so
extension=zip.so

  1. ls -l /usr/lib64/php/modules =

curl.so fileinfo.so gd.so json.so mbstring.so mcrypt.so mongo.so
phar.so zip.so


  1. A hello world PHP App print_something.php with the following line:
<?php
echo "Hello world\n";
?>
  1. php version is 5.6.0

  2. when run at the command line with:

    php print_something.php

I get the following output:

php print_something.php

PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib64/php/modules/mongo.so' – /usr/lib64/php/modules/mongo.so:
undefined symbol: file_globals in Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib64/php/modules/curl.so' – /usr/lib64/php/modules/curl.so:
undefined symbol: file_globals in Unknown on line 0 PHP Warning:

PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/json.so' – >/usr/lib64/php/modules/json.so: undefined symbol: executor_globals in Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/fileinfo.so' –
/usr/lib64/php/modules/fileinfo.so: undefined symbol: file_globals in
Unknown on l line 0

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/gd.so' –
/usr/lib64/php/modules/gd.so: undefined symbol: core_globals in Unknown on line 0

PHP Warning: PHP > Startup: Unable to load dynamic library '/usr/lib64/php/modules/mbstring.so' –
/usr/lib64/php/modules/mbstring.so: undefined symbol: sapi_globals in
Unknown on l line 0

PHP Warning: PHP Startup: mcrypt: Unable to initialize module Module compiled with module API=20090626 PHP compiled with module API=20131226 These options need to match in
Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/phar.so' –
/usr/lib64/php/modules/phar.so: undefined symbol: sapi_globals in
Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/zip.so' –
/usr/lib64/php/modules/zip.so: undefined symbol: executor_globals in
Unknown on line 0

Hello world


What I really need is mongo.so (I added the others just to make sure it wasn't a mongo issue alone). I've looked both general and specific searches on php shared modules not loading, and cannot find any answers on how to resolve this. If anyone can shed light on why these modules will not load, it would be really appreciated.

Best Answer

The PHP extensions are not compiled for this version of your PHP.

Same for missing symbols, because not linked against the correct PHP version.

Example from your errors: mcrypt

  • Module compiled with module API=20090626
  • PHP compiled with module API=20131226
  • These options need to match

Solution: Update the PHP extensions using your package management system to be in sync with PHP or compile them manually using PHP, the SDK and the extensions you want.

You find the Mongo Extension here: http://pecl.php.net/package/mongo