PHP Warning: PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib64/php/modules/zip.so (/usr/lib64/php/modules/zip.so: undefined symbol
Environment
- Red Hat Enterprise Linux
- PHP 7.x, 8.x
Issue
- php -m
PHP Warning: PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib64/php/modules/zip.so (/usr/lib64/php/modules/zip.so: undefined symbol: zip_register_cancel_callback_with_state), /usr/lib64/php/modules/zip.so.so (/usr/lib64/php/modules/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
- PHP Unable to load dynamic library
zip.so
after upgrade.
Resolution
Firstly, check there are no php-package conflicts. Remove/uninstall existing php-packages from system & then reinstall the latest PHP version from RHEL repositories.
-
With command
$ rpm -qa | grep php
one can check existing php packages. -
The library zip.so is not loaded because of missing libzip dependency of module
php-pecl-zip
.
Solution 1- Update libzip
dependency module manually using command # dnf update libzip
==================================================================================================================
Package Architecture Version Repository Size
==================================================================================================================
Installing:
php-pecl-zip x86_64 1.18.2-1.module+el8.3.0+6678+b09f589e @rhel-8-for-x86_64-appstream-rpms 134 k
Installing dependencies:
libzip x86_64 1.6.1-1.module+el8.3.0+6678+b09f589e @rhel-8-for-x86_64-appstream-rpms 112 k
Transaction Summary
==================================================================================================================
Remove 2 Packages
Solution 2- If one is able to see zip
module after running command # php -m and still getting Unable to load dynamic library 'zip.so'
error follow below steps:
$ ldd /usr/lib64/php/modules/zip.so
linux-vdso.so.1 => (0x00007fffcf696000)
libzip.so.5 => /usr/local/lib/libzip.so.5 (0x00007fad7a5e0000)
libc.so.6 => /usr/lib64/libc.so.6 (0x00007fad7a212000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00007fad79ffc000)
/lib64/ld-linux-x86-64.so.2 (0x00007fad7aa0e000)
- If output looks something like above, remove libzip.so.5 => /usr/local/lib/libzip.so.5 (0x00007fad7a5e0000) & rebuild it, as module libzip.so.5 is getting loaded from a different location.
- It should look like
libzip.so.5 => /lib64/libzip.so.5 (0x00007fad7a5e0000)
- It should look like
Root Cause
-
Dependency module is not updated.
-
To update PHP with its dependent modules use command
dnf module switch-to php:8.2
How to upgrade PHP in Red Hat Enterprise Linux 8/9?
Diagnostic Steps
Run the php -m command & check if zip module is present:
$ php -m
[PHP Modules]
...
xsl
Zend OPcache
**zip**
zlib
<END OF OUTPUT>
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments