If you recently upgraded your CentOS 7 PHP to version 7.3 (or probably 7.2) using remi repository, you might encounter an error complaining php-gd dynamic library failed to load when running any php command. You system may miss to upgrade an package which is used by php-gd library. It is an easy fix by install or upgrade the missing package.
Problem
Your have a system using CentOS 7 and the base repository comes with only PHP 5.4, which has been deprecated for a long time. You have just tried to upgrade it to a more recent PHP version 7.2 or later. One of most common way is using yum remi’s RPM repository. However, after the upgrade, the system returns this error for any PHP command:
PHP Warning: PHP Startup: Unable to load dynamic library 'gd' (tried: /usr/lib64/php/modules/gd (/usr/lib64/php/modules/gd: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/gd.so (/lib64/libraqm.so.0: undefined symbol: hb_ft_font_set_load_flags)) in Unknown on line 0
Note that the error mentioned "underfined symbol: hb_ft_font_set_load_flags"
. This symbol is coming from an package called HarfBuzz (https://harfbuzz.github.io/harfbuzz-hb-ft.html). HarfBuzz is a package providing face and font data support using FreeType, while php-gd is using. Your system most likely should have this package installed already but you might not have been keeping this package up to date. PHP 7.3 php-gd requires latest HarfBuzz which provides the missing symbol “hb_ft_font_set_load_flags”.
Solution
The simplest solution is to install or upgrade the HarfBuzz package to the latest version by using yum.
sudo yum install harfbuzz
After HarfBuzz upgraded to the latest version, the above PHP error should be gone.