I have an error in php 7.3 that I have been trying to solve for a while. Unable to load dynamic library 'gd2'.
I thought I had found the solution here: https://blog.amirasyraf.com/blog/php-startup-unable-to-load-dynamic-library-gd-so
I tried removing sudo apt purge php7.3-gd
and reinstalling it sudo apt update && sudo apt install php7.3-gd
but this did nothing to help. I have no libgd.so
files listed under /usr/local/lib
. I used locate libgd
and found /usr/lib/x86_64-linux-gnu/libgd.so.3
. I created a symlink from /usr/local/lib/libgd.so
to /usr/lib/x86_64-linux-gnu/libgd.so.3
and this did nothing to help.
uname -a
Linux 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux
php -v
PHP Warning: PHP Startup: Unable to load dynamic library 'gd2' (tried: /usr/lib/php/20180731/gd2 (/usr/lib/php/20180731/gd2: cannot open shared object file: No such file or directory), /usr/lib/php/20180731/gd2.so (/usr/lib/php/20180731/gd2.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.3.19-1~deb10u1 (cli) (built: Jul 5 2020 06:46:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.19-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.0RC2, Copyright (c) 2002-2019, by Derick Rethans
Can anyone help me solve this problem? What am I overlooking in trying to find a solution?
I encountered the same issue and went searching for the cause:
grep -r gd2.so /etc/php/7.4
and grep -r gd2.so /etc 2>/dev/null
this came up empty ...
... but omitting the .so
found the culprit:
grep -r gd2 /etc/php 2>/dev/null
/etc/php/7.4/cli/php.ini:extension=gd2
I edited the file /etc/php/7.4/cli/php.ini
and commented it out with ;
so it read ;extension=gd2
Now I do not get the error anymore
Note that this solution disables gd2. This will solve the issue only if you can live without the gd2 library