'attempting to run PHP returns php: symbol lookup error: php: undefined symbol: pcre2_set_depth_limit_8
I have installed PHP 7.4 through APT, but every time I try to run it, I receive the following error message:
php: symbol lookup error: php: undefined symbol: pcre2_set_depth_limit_8
running the command
ldd /usr/bin/php7.4 | grep pcre2
returns
libpcre2-8.so.0 => /usr/local/lib/libpcre2-8.so.0 (0x00007fa00625e000)
running the command
nm -gD /usr/local/lib/libpcre2-8.so.0 | grep depth
returns nothing, showing that the library does not contain the symbol. However, the library located in
/usr/lib/x86_64-linux-gnu/libpcre2-8.so.0
does contain the symbol. Running ldconfig -v does not appear to have any effect.
Note: I am using PHP, not PHP-fpm
I am using Ubuntu 21.04.
Solution 1:[1]
Removing the symlink in /usr/local/lib/libpcre2-8.so.0 and replacing it to point to /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0 seems to resolve this problem. Hope this helps anyone facing the same issue.
Solution 2:[2]
This one helped in my case,
sudo update-alternatives --set php /usr/bin/php7.4
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Oliver Jane |
| Solution 2 | Mûhámmàd Yäsår K |
